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];
}
Related
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 want images to be displayed dynamically, for ex- if user selects 10 images, all those should get displayed, now if user wants to select 5 more images, so (10+5) 15 images should get displayed. How to achieve this functionality?
I am using UIImagePickerController to select images, so at a time user will be able to select 1 image only.I have given a add photo button.
UIImagePickerController *galleryObj=[[UIImagePickerController alloc]init];
galleryObj.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
galleryObj.allowsEditing = YES;
galleryObj.delegate=self;
[self presentViewController:galleryObj animated:YES completion:nil];
Above will get executed when user taps on add photo button.
//GalleryViewcontroller.h
#import <UIKit/UIKit.h>
#interface GallaryViewController : UIViewController<UIImagePickerControllerDelegate>
{
NSMutableArray *selectedImagesArray;
}
#end
GalleryViewcontroller.m
#implementation GallaryViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
//allocating array
selectedImagesArray=[[NSMutableArray alloc]init];
}
-(IBAction)openGallery:(id)sender
{
UIImagePickerController *galleryObj=[[UIImagePickerController alloc]init];
galleryObj.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
galleryObj.allowsEditing = YES;
galleryObj.delegate=self;
[self presentViewController:galleryObj animated:YES completion:nil];
}
#pragma mark UIImagePickerController Delegate
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissViewControllerAnimated:YES completion:^{
//here we are adding the image in array
[selectedImagesArray addObject:[info objectForKey:UIImagePickerControllerOriginalImage]];
NSLog(#"%#",selectedImagesArray);
//reload your colleciton view or tableview or any other view which your using to show selected images
//you can get images by index
//UIImage *img=[selectedImagesArray objectAtIndex:0];
}];
}
#end
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
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i created nine buttons using IBOutletCollection here.
My question is - i want to get title which button is pressed and display it on another buttons title. Is this possible!
Try like this,
- (IBAction)buttonAction:(UIButton *)btn {
yourNextVCobject.buttonTitle = [NSString stringWithFormat:#"%#",btn.titleLabel.text];
// then push to ur vc.
}
In your Next VC,
In .h
#property (nonatomic, retain) NSString *buttonTitle;
In .m
[yourAnotherBtn setTitle:self.buttonTitle forState:UIControlStateNormal];
You can use the below code to set the title of clicked button to targetted another button.
-(IBAction)clickbutton:(id)sender
{
UIButton *firstButton = (UIButton *)sender;
NSString *neededtitle = [NSString stringwithformat:#"%#",firstButton.currentTitle];
[anotherbutton setTitle:neededtitle forState:UIControlStateNormal];
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How would I implement the searchBarSearchButtonClicked method? I am trying to pass the value of the search bar when the searchBarSearchButtonClicked to a label.
-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
[searchBar resignFirstResponder];
yourlabel.text = searchBar.text;
// DO what ever you want
}
Like so:
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
_myLabel.text = searchBar.text;
}
That's it!