Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to create a button that, when pressed, will open the Add Contacts Page of Phone Application. And once the Done/Cancel button is pressed, it should come back to my Application. I know this is possible, but i don't know how.
I think the Apple address book programming guide will help you:
ABNewPersonViewController *view = [[ABNewPersonViewController alloc] init];
view.newPersonViewDelegate = self;
UINavigationController *newNavigationController = [[UINavigationController alloc]
initWithRootViewController:view];
[self presentModalViewController:newNavigationController
animated:YES];
ABNewPersonViewController is deprecated with iOS9. One should use CNContactViewController instead. Unfortunately there is a bug, refer to this thread (CNContactViewController Bug).
CNContactStore().requestAccessForEntityType(.Contacts) {ok, err in
guard ok else {return} // only if access is granted
dispatch_async(dispatch_get_main_queue()) {
let con = CNMutableContact()
let unkvc = CNContactViewController(forUnknownContact: con)
unkvc.contactStore = CNContactStore()
unkvc.delegate = self
unkvc.allowsActions = false
self.presentViewController(unkvc, animated: true, completion: nil)
}
and the delegate methods:
func contactViewController(vc: CNContactViewController, didCompleteWithContact con: CNContact?)
func contactViewController(vc: CNContactViewController, shouldPerformDefaultActionForContactProperty prop: CNContactProperty) -> Bool
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I would like to make a simple ViewController with two or three Buttons and labels. When I press the Button it plays an audio file.
I want to make hundreds of this similar screen, what is the best way to create it? (I am currently creating it with MainStoryBoard.)
For each page I would like to make small changes such as Buttons sizes ,Buttons numbers, label texts and audio files.
Drawing text bubbles or using xib file might be good, but I am not sure what I should.
You first need to have your own class for this UIViewController as a base class that has buttons, labels, etc.
Then use Factory Design pattern to generate the inherited UIViewController class which allows you to do some tweak that fits you need.
Factory Design Pattern
BaseViewController {
UIButton *button1;
UIButton *button1;
UILabel *label1;
}
ChildViewControllerA : BaseViewController {
UIButton *button3
}
ChildViewControllerB : BaseViewController {
UIButton *button4
}
Factory : NSObject {
+ (BaseViewController)generateChildViewController: (int) type {
switch (type)
case 0:
return [[ChildViewControllerA alloc] init];
case 1:
return [[ChildViewControllerB alloc] init];
}
}
Main {
- (void)createThreeViewControllers {
BaseViewController *vc1 = [Factory generateChildViewController:0];
vc1.button1.backgroundColor = [UIColor blueColor];
BaseViewController *vc2 = [Factory generateChildViewController:0];
vc2.button2.center = cgpointmake (100, 150);
BaseViewController *vc3 = [Factory generateChildViewController:0];
vc3.label1.text = #"vc3 test";
}
}
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I have a method in my app that checks to see if some things are true.
- (BOOL)isToggleTurnedOn {
return ([self checkToggleStatus] != [self checkOtherToggle]);
}
When this method returns true, I display a modal.
if ([Preferences isToggleTurnedOn] == true) {
NSArray *welcomeTexts = #[
...
some data
...
];
WelcomeController *welcomeController = [[WelcomeController alloc] initWithText:welcomeTexts];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:whatsNewController];
navController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navController animated:YES completion:nil];
}
Now, this code is not as beautiful as it could by, in my opinion. I'd rather add the presentation of the controller as a parameter of isToggleTurnedOn. What's the best way to refactor this?
- (BOOL)isToggleTurnedOn {
return [self checkToggleStatus] != [self checkOtherToggle]
}
Drives me crazy to see code like this. Be more succinct:
- (BOOL)isToggleTurnedOn {
return ([self checkToggleStatus] != [self checkOtherToggle]);
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have on Unbutton and i want to open detail page on hard press on it.
so how it possible let me know.
#pragma mark - Previewing delegate
- (UIViewController *)previewingContext:(id <UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location
{
UIViewController *detailVC = [self.storyboard instantiateViewControllerWithIdentifier:#"detail"];
detailVC.preferredContentSize = CGSizeMake(0.0, 568.0);
previewingContext.sourceRect = self.btnDetail.frame;
return detailVC;
}
- (void)previewingContext:(id <UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit{
[self showViewController:viewControllerToCommit sender:self];
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
In a master detail, there is a "back" button present when looking at the details, but how do I add a "forward" button? Tapping on it takes the user to the next record/detail.TableView example image
Tapping on the ">", will take take the user to the "kate bell". The work around would be to go to "all contacts", and then tap on "kate bell"
I am unfamiliar with Obj-C, and I am learning swift.
I wrote this in swift.
navigationItem.rightBarButton = UIBarButtonItem( title: "Next", style: .Plain, target: self, action: "next")
#IBAction func next () { }
The following code will add an item to the right side of the navigation bar, and call the -forwardAction: method when tapped;
-(void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:#"title" style:UIBarButtonItemStylePlain target:self action:#selector(forwardAction:)];
self.navigationItem.rightBarButtonItem = button;
// ...
}
-(IBAction)forwardAction:(id)sender {}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i just want to ask about the universal app that i have created a universal app with two different storyboard one for iphone and other for ipad , lets assume i created a viewcontroller in both storyboards called mainview so should i create different classes for the storyboard of iphone and ipad or should i create one class and assign to both mainview iphone and mainview ipad .
ignore the code below
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:[NSString stringWithFormat:#"%#",[ApplicationUtility getPlistData:KEY_REGISTER_DATA]] delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
NSString *str = [NSString stringWithFormat:#"%#",[ApplicationUtility getPlistData:KEY_REGISTER_DATA]];
NSLog(#"%#",str);
if([str isEqualToString:#"Signed up successful"])
{
username.text = #"";
firstname.text = #"";
lastname.text = #"";
email.text = #"";
supass.text = #"";
suconfirmpass.text = #"";
country.text = #"";
postal.text = #"";
dob.text = #"";
titl.text = #"";
[priv1 setSelected:NO];
[priv2 setSelected:NO];
[male setSelected:NO];
[female setSelected:NO];
}
Yes you should create one class for both storyboards if you can, so if you have any special treatment for any, you can put some if statements in your code.
You can take a look at Apple's doc here.
in storyboard u should call a ipad storybard on ipad condition and u shoud call iphone storyboard on iphone condition and condition is below...
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad)
{
//for iphone storyboard
}
else
{
//for ipad storyboard
}