How to create Marquee IOS Clickable - ios

Can you help me in how we can create a marquee for news , but I need that every new be clickable to show the detail page of the selected new.
I know we have many of examples considering marquee but no one was clickable for every item in the marquee.
Please help me

If you use something like this:
https://www.cocoacontrols.com/controls/marqueelabel
I'm assuming you should have NSArray of news. Put first news into marquee label as a text and start animating it.
You may be notified when marquee view reaches end scrolling (animating) then, put second news.
That's how you know which news user's currently viewing.
To be able to click on marquee and get notification:
UITapGestureRecognizer *tap =
[[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(userDidTapOnNews:)];
[marquee addGestureRecognizer: tap];
-(void)userDidTapOnNews:(UITapGestureRecognizer *)gestureRecognizer
{
// Marquee tapped, your turn ...
// Use gestureRecognizer parameter if you need the view tapped
Marquee *marque = gestureRecognizer.View;
...
// Get news from your news `NSArray`
}
Hope it helps

Related

Multiple UIGestureRecognizers in Xcode/Swift

Right now, I have two different UILabels each with their own long press and pan UIGestureRecognizers (setup through the storyboard). My final goal is to have each UILabel change color when long pressed, and without lifting their finger to end the long press, to change the value of the UILabel itself when the user pans up and down or side to side.
Right now, each UILabel has its own pan gesture method and long press gesture method. Is there any way to have a single long press/pan method for both UILabels but also have the ability to do something for one label and something else for another?
Also, is there a better approach to doing this? Eventually, I would also like to implement visual feedback when changing the value of the labels, such as in the form of animations.
I am new to iOS programming and programming in general and detailed answers are greatly appreciated. Thanks.
You can have a single function.No need to have seperate gestures for seperate Label.Example
//First add tag value to ur labels
label_one.tag=1;
label_two.tag=2;
UIPanGestureRecognizer * _panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self
action:#selector(handlePanGesture:)];
_panGestureRecognizer.delegate = self;
[label_one addGestureRecognizer:_panGestureRecognizer];
UIPanGestureRecognizer * _panGestureRecognizer_two = [[UIPanGestureRecognizer alloc] initWithTarget:self
action:#selector(handlePanGesture:)];
_panGestureRecognizer_two.delegate = self;
[label_two addGestureRecognizer:_panGestureRecognizer_two];
-(void)handlePanGesture:(UIPanGestureRecognizer*)sender{
if(sender.tag==1){
}
else if(sender.tag==2){
}
}
Same goes for other gesture as well

How can I make a scrollable label that contains clickable links?

In my app I've created a small RSS feed reader that shows the titles of the news. I've simply put the titles in a single string and I'm showing them in a scrolling MarqueeLabel. I'd like to make the titles clickable to show the linked news and I've tried to do so following this answer, but the string is not interactable at all, even if it is highlighted as a hyperlink.
Is there an easy way to make it work? I've tried to look if there are libraries that combine both the scrolling and the linking functionalities, but I couldn't find any.
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:#selector(handleTap:)];
[marqueeLabel addGestureRecognizer:tapGesture];
-(void)handleTap:(UITapGestureRecognizer *)gesture{
MarqueeLabel *marqueeLabel = (MarqueeLabel*) [gesture view];
NSLog(#"Clicked Link would be %#",marqueeLabel.text);
}
NB:Just add UITapGestureRecognizer to your desired label and handle it

Accessibility label wih iOS ViewController presented as a form sheet

I am making use of a Presentation: Form Sheet in my app. So my ViewController gets displayed as a form with the black semi-transparent overlay around it.
I have implemented the logic to dismiss everything should the user tap anywhere outside my form sheet ViewController.
I would like to test this behavior but I'm not sure how to simulate the tap. How can I set an accessibility label to simulate this tap with a UI test?
Or any other suggestions how I can test this behavior?
Thanks!
You just want to click anywhere on the screen to dismiss everything?
[tester tapScreenAtPoint:CGPoint];
does that for you.
Most stuff about KIF is explained here:
http://www.raywenderlich.com/61419/ios-ui-testing-with-kif
Hi you can use UITapGestureRecognizer like this :
First create an instance of UITapGestureRecognizer
UITapGestureRecognizer *tapGesture = tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(someMethod:)];
Then attach this gesture recognizer to your view (i.e, black overlay you're talking about )
[self.view addGestureRecognizer:tapGesture];
Then implement someMethod: which is the method (action) that gets called when your formsheet is tapped
-(void)someMethod
{
//Logic to dismiss your formsheet
}
HTH :D

How to open a view(another xib) on clicking of a uiimage in ipad application

How to open a view(another xib) on clicking of a uiimage in ipad application .Please tell me if anyone knows thanks in advance.
i read somewhere that it can be done by using custom delegates of class ,but i not able to implement it.
first of all you have to make the user interaction for imageView in xib enable as shown in illustration see
now add one tapgastureREcognizer as below
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:#selector(tapAction:)];
tapGesture.numberOfTapsRequired = 1;
tapGesture.numberOfTouchesRequired = 1;
[fr addGestureRecognizer:tapGesture];
here fr is the imageview and the tapAction: is method where you can show the other view (xib)
There are two ways I have done this in the past.
A) create a UIButon and set the image as its background.
B) You can create touch gesture recogniser. Upon touch you can get the coordinates of where the user touched and check to see if it was in fact on the image.
The you just display your other view.

How do I subclass UISegmentedControl so that individual segments recognize a UILongPressGestureRecognizer?

First off this question has been helpful in my understanding of how to subclass UIButton for long presses. I would like to do the same for UISegmentedControl, however I don't see how I would be able to identify which segment was held down since UISegmentedControl does allow direct access to it's segments (UISegmentedControl.h shows them as private). I could just customize a few UIButtons to look like an UISegmentedControl however I would also have to implement the momentary switch logic. Which wouldn't be a big deal but subclassing UISegmentedControl seems cleaner to me.
BTW, I'm using this control to imitate a radio's preset controls: tap to go to a saved station and hold to assign the current station to that segment.
I tried this without subclassing and it seems to work.
UILongPressGestureRecognizer* recognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:#selector(pressGesture:)];
recognizer.delegate = self;
[mySegCtrl addGestureRecognizer:recognizer];
[recognizer release];
...
-(void)pressGesture:(UILongPressGestureRecognizer*)gesture
{
NSLog(#"pressGesture %#", gesture);
}
Long press first selects the segment then fires the gesture. If you aren't getting the callback check my code - I got stuck for a while because I wasn't setting recognizer.delegate=self.

Resources