i am new to iPad developer,
i have created two or three iPad application in objective c using Xcode 4.
but now i want to create iPad application using Monodeveloper tool in C# language...
in which, i want to insert Refresh button, on my NavigationBar,
here is my code snippet,
UIBarButtonItem button=new UIBarButtonItem(UIBarButtonSystemItem.Refresh);
NavigationItem.LeftBarButtonItem=button;
i am able to see refresh button on my NavigationBar, but when i click it, my view doesn't refreshes.
how to refresh view, any idea ?
Thanx In Advance !!
Any Help Will be Appriciated.
You are initializing a UIBarButtonItem without a handler. So tapping the button does nothing.
Try this:
UIBarButtonItem button =
new UIBarButtonItem(UIBarButtonSystemItem.Refresh,
(s, e) => Console.WriteLine("Refresh!"));
You can also assign it after initialization:
UIBarButtonITem button = new UIBarButtonItem(UIBarButtonSystemItem.Refresh);
button.Clicked += (s, e) => Console.WriteLine("Refresh!");
EDIT:
Inside the handler, you must implement your own "Refresh" code, depending on what it is you want to refresh. The UIBarButtonSystemItem enumeration merely defines the appearance of UIBarButtonItem buttons.
Related
I'm working on a new codebase that has everything laid out in storyboards and I'm trying to implement the new ASAuthorizationAppleIDButton button as part of the new Sign In With Apple feature.
Reading online it looks like I can add a UIButton to the view and then override the class to be ASAuthorizationAppleIDButton. Easy enough. The weird parts comes when I try and wire that button up to an action in the VC. I can't do it. Even if I go the other way and drag from the button to the VC, the action item is missing from the connection menu.
Has anyone had success adding and interacting with this button from a storyboard? I'd prefer not to redo the entire view just because of this one issue.
ASAuthorizationAppleIDButton is not a button but its a control. And this is stated in that way to avoid misuse of this as a button. And only one action is associated with it which cannot be override. The only control you get is to use the delegate method of
didCompleteWithAuthorization & didCompleteWithError.
So if you want to use/include some extra selector or methods. you can add those in these delegate- methods.
I am new to Swift and app development. I have a design question. I am trying to make a view that contains a slider, but that as soon as the "touch up inside" action is performed, is replaced by a progress bar + button. If the button is pressed, then we go back to showing only the slider. This view will be not take the whole screen, only part of it.
What would be the best way of doing this? I have already investigated several options:
1. using a navigation controller with a segue triggered by the slider that goes into a new scene with a progress bar & button.
2. creating a custom view with two properties: a slider and a custom view (progress bar & button). The slider can be laid out using interface builder, and the custom view can be loaded from a nib file when needed.
3. creating a custom view with two properties: a slider and a custom view (progress bar & button). The new progress bar and button are created programmatically whenever the action is triggered on the slider.
I have already tried options 1 and 2 to some extent with no success. Since I am a beginner, I am trying to use the IB as much as possible. What is the best option (if any) from the list?
You can do this directly on the Storyboard without needing to create a custom view class, but you'll need a few lines of code in any case. Just drag a Slider into your View, and then drag a button and a progress view directly on top of that. Now select the button, and in the Attributes inspector, tick the box next to "Hidden". Do the same with the progress bar. Then just open the assistant editor and connect references to all 3 of those. You'll also need to create an action for the button (I've called it change), and make sure you leave the type field as AnyObject. Add the following line inside ViewDidLoad:
slider.addTarget(self, action: Selector("change:"), forControlEvents: .TouchUpInside)
This line just makes it so that change gets called anytime the user uses the slider. Obviously change slider to whatever you name your UISlider. You can implement the change function like this:
#IBAction func change(sender: AnyObject) {
slider.hidden = !slider.hidden
button.hidden = !button.hidden
progressBar.hidden = !progressBar.hidden
}
This is a simple implementation that just toggles between true and false for each of the items, but you'll probably want to do it differently depending on what this project does.
Now, if you want to put this functionality in multiple places in your app it might be easiest to create a custom view using the same concept as above, in which case check out this tutorial on how to create an IBDesignable UIView.
I have a screen in which the user is doing some actions.
When clicking the back button, I want to stop and show an alert to confirm this step.
I have 2 options:
Leave the native back button: < Prev screen and catch the -(void) viewWillDisappear:(BOOL)animated. when I'm doing that, It is too late to go back. I can't stop the back action, can I?
Replace with custom button. That's the easy solution, except I don't have the < on the button... Adding this sign as an image looks too cumbersome.
Does anyone have an idea how to solve this?
The right way is to create a custom UIBarButtonItem with the right type. Using an image is not painful at all.
And no, there is no use trying to prevent the pop action on UINavigationController. Also mind the InteractivePopGestureRecognizer as of iOS 7.
UIButton *button= [UIButton new];
//customize your button here
UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc]initWithCustomView:button];
self.navigationItem.leftBarButtonItem = leftBarButton;
customize your button with your title etc...
My ViewController contains WebView and invisible button over (or below) the WebView. (see image). I want that the button to be clickable. But(!) in the case there are some links in the WebView, the links should be clicked, not the button.
How can I do it?
Similar issue discussed here:
Add UIButton in a UIWebView
However, in my case, I need links that are clickable also not be scrolling enabled.
If all you need is to be able to still drag the UIWebView around while still being able to receive a button press on a certain part on the view, you don't need to place a button below it in order to achieve that.
UIButton can still be able to receive touch even if it is completely transparent.
yourButton.backgroundColor = [UIColor clearColor];
[yourButton addTarget:self action:#selector(pressed)forControlEvents:UIControlEventTouchUpInside];
This way the button would only receive the press and will not affect your dragging of the web view - it will ignore the dragging but respond only to the press.
Tested on a scrollable view with a clear UIButton.
Hope this helps.
I have a iPad app with the following code tied to a button's (bMyDocuments) TouchDown event handler:
UIPopoverController uipoc = new UIPopoverController(new Pop2());
uipoc.PopoverContentSize = new SizeF(200f, 300f);
uipoc.PresentFromRect (bMyDocuments.Frame, v, UIPopoverArrowDirection.Up, true);
Pop2 is a blank UIViewController with the default view (white background, no ui elements).
This code produces a popover from the button, and the size is correct. However the app hangs without any errors, and popover won't disappear when clicking outside of it.
How can I initialize UIPopoverController correctly? Sample code?
thanks,
pom
Chances are that the garbage collector is eating up your UIPopoverController. Try declaring your UIPopovercontroller as a class variable instead of inside your TouchDown event and see how that goes.
Cheers,
ChrisNTR