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
}
Related
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 7 years ago.
Improve this question
Hi i am beginner in Ios in my project i am crating one registration page and there i have to provide validations for textfields as like best level and i have searched for this so many textfield validations tutorials but i did not get correct one
According to my requirement when i clicked on textfield if there is any error then need to show alert message on textfields like below screen for this i have written so many custom methods but they are not working please help me some one
You have to make your custom view for validate the textFields
You can try to do it with https://github.com/ustwo/US2FormValidator
Code in reference to Objective-C
US2ValidatorTextField *firstNameTextField = [[US2ValidatorTextField alloc] init];
firstNameTextField.validator = [[[MyProjectValidatorName alloc] init] autorelease];
firstNameTextField.shouldAllowViolation = YES;
firstNameTextField.validateOnFocusLossOnly = YES;
firstNameTextField.placeholder = #"Enter first name";
firstNameTextField.validatorUIDelegate = self;
[_textUICollection addObject:firstNameTextField];
[firstNameTextField release];
Hope it helps you.
I've written many UITextField validators and its always best to do this sort of thing yourself as each requirement is different and there is more control over it.
The best time to validate is normally when UItextField did end editing - this way you know the user is done.
You need to look at UITextFields delegate methods and use the text argument from there to check length and that sort of thing.
I can't supply any code as you haven't stated what sort of validation you want done. If its email - this is the sort of thing you need (Its in Objective-C though)
/* Email address validation test */
NSString *emailReg = #"[A-Z0-9a-z._%+-]+#[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:#"SELF MATCHES %#", emailReg];
if ([emailTest evaluateWithObject:emailAddress]){
validEmail = YES;
}
Its like you can implement this with simple code as like checking and showing an alert.
if the textfield is empty
if the textfield contains numbers
if the textfield is a email field
if the all the required text field is filled
you can achieve this by using this piece of code
// To check the email field is not empty string
if([[self.email text] isEqualToString:#""]){
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:#"Warning" message:#"Enter your email!" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alertView show];
}
// To check the email field has '#' empty string
else if ([self.email.text rangeOfString:#"#"].location == NSNotFound){
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:#"Warning" message:#"Enter proper email!" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alertView show];
}
you can implement like this or you can use libraries depending on your requirement.
There is an issue with an UIAlertView when i add to this a lot of buttons. Then the alertView seems to be destroyed. This happens only to prior version of iOS 7. On iOS 7 and posterior versions it seems ok.Here is a screenshot of my problem.Can i fix it?
- (void) sortTotalMnhmeia{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Ταξινόμηση" message:#"Επιλέξτε είδος ταξινόμησης" delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"Αξιοθέατα",#"Δραστηριότητες",#"Διαμονή",#"Χωριά",#"Προϊόντα",#"Όλες οι κατηγορίες",nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0)
{
NSLog(#"Cancel Tapped.");
}
else if (buttonIndex == 1)
{
[self.mapView removeAnnotations:self.annotations];
[self.annotations removeAllObjects];
self.annotations=[[NSMutableArray alloc] init];
NSLog(#"yo %d",self.annotations.count);
for(int i=0; i<self.allGroups.count; i++){
Group *assistantGroup=assistantGroup=[self.allGroups objectAtIndex:i];
if ([assistantGroup.secondLevel intValue]==1) {
if ([assistantGroup.thirdLevel intValue]==1) {
self.chooseMarker=#"Museum";
}
else if ([assistantGroup.thirdLevel intValue]==2) {
self.chooseMarker=#"Art";
}
else if ([assistantGroup.thirdLevel intValue]==3) {
self.chooseMarker=#"Religious";
}
else if ([assistantGroup.thirdLevel intValue]==4) {
self.chooseMarker=#"Monument";
}
else if ([assistantGroup.thirdLevel intValue]==5) {
self.chooseMarker=#"Natural";
}
else if ([assistantGroup.thirdLevel intValue]==6) {
self.chooseMarker=#"Beach";
}
NSLog(#"************ %# %# %#",assistantGroup.title,assistantGroup.latitude,assistantGroup.longitude);
Annotation *ann = [[Annotation alloc] initWithLong:[assistantGroup.longitude doubleValue] Lat:[assistantGroup.latitude doubleValue] iconNumber:0];
ann.title = assistantGroup.title;
ann.subtitle=#"";
ann.type=self.chooseMarker;
[self.annotations addObject:ann];
}
//ann.type=assistantGroup.kind;
}
[self.mapView addAnnotations:self.annotations];
}
.....
}
You should consider using a modal view controller instead since using lots of buttons in an AlertView can be confusing. I don't see the reason adding lots of buttons to a single alert view. A modal VC has all the flexibility you are looking for. Otherwise an action sheet would be preferable too.
But to answer the question: Add a "More" button last that spawns a second AlertView with the buttons that don't fit the first alert view. Alert VCs don't rescale the way they do on iOS versions above 7.0.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have an if statement that is working fine, but I need to add a 2nd if statement inside of it and I can't seem to figure out how to get it right.
Here is my code:
-(IBAction)xButton {
if([_hasUserTakenAPhoto isEqual: #"YES"]) {
_xButtonAfterPhotoTaken = [[UIActionSheet alloc] initWithTitle:#"Delete" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:nil];
[_xButtonAfterPhotoTaken showInView:self.view];
NSString *title = [_xButtonAfterPhotoTaken buttonTitleAtIndex:1];
if(title isEqualToString:#"Delete") {
[self performSegueWithIdentifier:#"backToHomeFromMediaCaptureVC" sender:self];
}
} else {
[self performSegueWithIdentifier:#"backToHomeFromMediaCaptureVC" sender:self];
}
}
I get errors when I add in the 2nd if statement of:
if(title isEqualToString:#"Delete") {
[self performSegueWithIdentifier:#"backToHomeFromMediaCaptureVC" sender:self];
}
I have tried making the 2nd if statement an "else if" but then it will not let me access the NSString object called "title". Is there an easier way to do this, or should I just make title a global variable?
UIActionSheets are not used that way:
- (IBAction)xButton:(UIButton*)sender
{
if ([_hasUserTakenAPhoto isEqual:#"YES"])
{
_xButtonAfterPhotoTaken = [[UIActionSheet alloc] initWithTitle:#"Delete Photo?" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:#"Delete" otherButtonTitles:nil];
[_xButtonAfterPhotoTaken showInView:self.view];
}
else
{
[self performSegueWithIdentifier:#"backToHomeFromMediaCaptureVC" sender:self];
}
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
// Check if it's the correct action sheet and the delete button (the only one) has been selected.
if (actionSheet == _xButtonAfterPhotoTaken && buttonIndex == 0)
{
[self performSegueWithIdentifier:#"backToHomeFromMediaCaptureVC" sender:self];
}
}
- (void)actionSheetCancel:(UIActionSheet *)actionSheet
{
NSLog(#"Canceled");
}
You gotta understand that interface elements are not "instant", there's plenty of asynchrony going on. When presenting an UIActionSheet for instance, the thread doesn't wait for the user to answer yes or no, it keeps running.
That's why there's delegates, and blocks, you present the UIActionSheet, and with the delegate you say "I'll take care of it when the user actually clicks it".
You'd be wondering, why not just wait for it to select it? Main thread takes care of updating the interface, animations, and retrieving user input (touches, keyboard taps, etc) and even running NSTimers that are subscript to the main NSRunLoop. Stopping main thread would lock the interface.
Try
- (IBAction)xButton
{
NSString *title;
if ([_hasUserTakenAPhoto isEqual:#"YES"])
{
_xButtonAfterPhotoTaken = [[UIActionSheet alloc] initWithTitle:#"Delete" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:nil];
[_xButtonAfterPhotoTaken showInView:self.view];
title = [_xButtonAfterPhotoTaken buttonTitleAtIndex:1];
if ([title isEqualToString:#"Delete"])
{
[self performSegueWithIdentifier:#"backToHomeFromMediaCaptureVC" sender:self];
}
}
else
{
[self performSegueWithIdentifier:#"backToHomeFromMediaCaptureVC" sender:self];
}
}
This question already has answers here:
How to use an UIActionSheet within an if statement? [closed]
(2 answers)
Closed 9 years ago.
I have an if else if statement that is giving me trouble.
First, here's my code:
if([_hasUserTakenAPhoto isEqual: #"YES"]) {
_xButtonAfterPhotoTaken = [[UIActionSheet alloc] initWithTitle:#"Delete" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:nil];
[_xButtonAfterPhotoTaken showInView:self.view];
_xButtonActionSheetTitle = [_xButtonAfterPhotoTaken buttonTitleAtIndex:0];
} else if ([_xButtonActionSheetTitle isEqualToString:#"Delete"]) {
[self performSegueWithIdentifier:#"backToHomeFromMediaCaptureVC" sender:self];
} else {
[self performSegueWithIdentifier:#"backToHomeFromMediaCaptureVC" sender:self];
}
My problem is that I need to perform the method call of:
[_xButtonActionSheetTitle isEqualToString:#"Delete"] and if it is equal to "Delete", then I need to perform a segue using this method call:
[self performSegueWithIdentifier:#"backToHomeFromMediaCaptureVC" sender:self];
The only way I know how to do this is with another if statement, which you can see in my original code I started with "else if", but this creates different scope for all of my action sheet statements.
I just need to make the title of "Delete" on my action sheet tappable and it needs to trigger the segue.
I was trying to follow this action sheet answer here: https://stackoverflow.com/a/17374248/3117509
I just can't seem to figure this out.
Closing question. The problem is that I do not have a solid grasp on UIActionSheets.
I am new to IOS. I am making a login view controller in IOS with one button which is sign in. I have two possible view-controllers that might be shown when the user click on the sign-in button. I am using Storyboard but I can only assign one segue to one button. I don't know how to perform the condition since I seem not to have 100% control over the segue.
Here is my code:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *stringreponse=[[NSString alloc] initWithData:_responseData encoding:NSUTF8StringEncoding];
// NSLog(#"Split response %#", [splitresponse objectAtIndex:0]);
if([stringreponse isEqualToString:#"0"])
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:#"Wrong username or password" message:#"Wrong username or password" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
}
else
{
NSArray *splitresponse=[stringreponse componentsSeparatedByString:#"#"];
if([[splitresponse objectAtIndex:0] isEqualToString:#"Parent"])
{
if([[splitresponse objectAtIndex:2] isEqualToString:#"yes"])
{
//seguechoice=#"showParentRegistration";
//[self performSegueWithIdentifier:#"showParentRegistration" sender:self ];
}else{
//seguechoice=#"showSohoDashboard";
}
}
}
}
you can assign one segue to one UI control but you can assign many to a viewContoller. Simply add all of them to the viewController, give each a different id and then call those id's
if([[splitresponse objectAtIndex:2] isEqualToString:#"yes"])
{
[self performSegueWithIdentifier:#"showParentRegistration" sender:self ];
}
else
{
[self performSegueWithIdentifier:#"showSohoDashboard" sender:self ];
}
Create 2 connection in storyboard from your source view controller to destination view controller (not button). Insert two different identifiers and when the button is pressed do condition and run a segue depends on the condition:
if(CONDITION TO RUN SEGUE !)
{
[self performSegueWithIdentifier:#"SEGUEIDENTIFIER1" sender:self ];
}else {
[self performSegueWithIdentifier:#"SEGUEIDENTIFIER2" sender:self ];
}