problem in changing size of uialertview - iphone

Hello
I am having a alertview and i want to change the size by cgrectmake property but it does not happen .
It just take the by default size.
i tried following code.
- (void)viewDidLoad {
[super viewDidLoad];
UIAlertView* find = [[[UIAlertView alloc] init]initWithFrame:CGRectMake(0,0,300,200)];
[find setDelegate:self];
[find setTitle:#"Sample Alert"];
[find setNeedsLayout];
[find show];
[find release];
}
Thanks in advance .

To achieve what you want, in your code, after:
[find show];
add:
find.frame = CGRectMake(0,0,300,200);
It's not pretty though, I suggest you use ActionSheets.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Confirmation" message:#" Submit the answer " delegate:self cancelButtonTitle:#"NO" otherButtonTitles:#"YES", nil];
[alert show];
[alert release];
UILabel *theTitle = [alert valueForKey:#"_titleLabel"];
[theTitle setTextColor:[UIColor blackColor]];
UILabel *theBody = [alert valueForKey:#"_bodyTextLabel"];
[theBody setTextColor:[UIColor blackColor]];
UIImage *theImage = [UIImage imageNamed:#"blue-white-abstract-background.jpg"];
theImage = [theImage stretchableImageWithLeftCapWidth:10 topCapHeight:10];
CGSize theSize = [alert frame].size;
UIGraphicsBeginImageContext(theSize);
[theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];
theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//[[alert layer] setContents:[theImage CGImage]];
[[alert layer] setContents:[UIColor clearColor]];
This code does a lot of things to alertview and modify it to increase the size of the alert view.

This does the job pretty well, and does not look weird when the alert appear (ahmet emrah solution has a pretty bad side effect).
CGAffineTransform myTransform = CGAffineTransformMakeScale(1.0, 0.5f);
[alert setTransform:myTransform];

You can subclass the UIAlertView. I have done something like this, change it for your need.
Header file,
#import <Foundation/Foundation.h>
/* An alert view with a textfield to input text. */
#interface AlertPrompt : UIAlertView
{
UITextField *textField;
}
#property (nonatomic, retain) UITextField *textField;
#property (readonly) NSString *enteredText;
- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle okButtonTitle:(NSString *)okButtonTitle;
#end
Source code,
#import "AlertPrompt.h"
#implementation AlertPrompt
static const float kTextFieldHeight = 25.0;
static const float kTextFieldWidth = 100.0;
#synthesize textField;
#synthesize enteredText;
- (void) drawRect:(CGRect)rect {
[super drawRect:rect];
CGRect labelFrame;
NSArray *views = [self subviews];
for (UIView *view in views){
if ([view isKindOfClass:[UILabel class]]) {
labelFrame = view.frame;
} else {
view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y + kTextFieldHeight , view.frame.size.width, view.frame.size.height);
}
}
CGRect myFrame = self.frame;
self.textField.frame = CGRectMake(95, labelFrame.origin.y+labelFrame.size.height + 5.0, kTextFieldWidth, kTextFieldHeight);
self.frame = CGRectMake(myFrame.origin.x, myFrame.origin.y, myFrame.size.width, myFrame.size.height + kTextFieldHeight);
}
- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle okButtonTitle:(NSString *)okayButtonTitle
{
if (self = [super initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:okayButtonTitle, nil])
{
// add the text field here, so that customizable from outside. But set the frame in drawRect.
self.textField = [[UITextField alloc] init];
[self.textField setBackgroundColor:[UIColor whiteColor]];
[self addSubview: self.textField];
// CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 20.0);
// [self setTransform:translate];
}
return self;
}
- (void)show
{
[textField becomeFirstResponder];
[super show];
}
- (NSString *)enteredText
{
return textField.text;
}
- (void)dealloc
{
[textField release];
[super dealloc];
}
#end

Related

EXC_BAD_ACCESS(Code=1…. when using NSObject as a delegate

I have this code in the .h file :
#import <UIKit/UIKit.h>
#interface NFModalPickerView : NSObject
#end
#protocol NFModalPickerViewDelegate<NSObject>
#optional
- (void)titleSelected:(NFModalPickerView *) modalPickerView title:(NSString *) title;
#required
- (void)done:(NFModalPickerView *) modalPickerView;
#end
#interface NFModalPickerView()
{
id <NFModalPickerViewDelegate> delegate;
}
#property (nonatomic, strong) NSMutableArray * objectArray;
#property (nonatomic, strong) id <NFModalPickerViewDelegate> delegate;
- (void) show;
#end
and this code in the .m file :
#import "NFModalPickerView.h"
#interface NFModalPickerView()<UIPickerViewDelegate,UIPickerViewDataSource>
#end
#implementation NFModalPickerView
#synthesize objectArray;
#synthesize delegate;
UIActionSheet *actionSheet;
UIPickerView *pickerView ;
UISegmentedControl *closeButton;
- (void) show{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;
[actionSheet addSubview:pickerView];
pickerView = nil;
closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:#"Done"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:#selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
closeButton = nil;
[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return [objectArray count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
return [objectArray objectAtIndex:row];
}
-(void) dismissActionSheet:(id)sender {
UIActionSheet *actionSheet = (UIActionSheet *)[(UIView *)sender superview];
[actionSheet dismissWithClickedButtonIndex:0 animated:YES];
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
[[self delegate] titleSelected:self title:[objectArray objectAtIndex:row]];
}
#end
and finally this code in my ViewController
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
pickerView = [[NFModalPickerView alloc] init];
pickerView.objectArray = [[NSMutableArray alloc] init];
[pickerView.objectArray addObject:#"Don personnel"];
[pickerView.objectArray addObject:#"Don d'entreprise"];
[pickerView setDelegate:self];
[pickerView show];
return NO;
}
I'm always getting a bad access error when using NFModalPickerView as the delegate of the pickerview. If i put all the code in the view controller using the view controller as the delegate of the picker view it works fine. I need to have a separate class to reuse the modalpickerview and not always put all the code in each of my view controllers. Anyone can help me with this?
If you are using ARC, UIPickerView 's delegate might be auto-released. Either use the UIViewController as the dataSource and the delegate for the UIPickerView, or if you are using a separate object to manage the UIPickerView, keep it as a property so that it is not released.

How to set height and width of a UIAlertView?

I have a UIAlertView with an image and a large button.
The problem is that the default UIAlertView is a very small size. It's image cannot be seen properly.
So, I want to increase the height and width of the UIAlertView. In other words, I want to create a custom UIAlertView. What would be the way to do that?
Thanks.
I am sending you my code, I am showing a TableView in AlertView, perhaps it will help you.
in header file paste this code.
#import <UIKit/UIKit.h>
#interface aaViewController : UIViewController <UIAlertViewDelegate, UITableViewDelegate, UITableViewDataSource>{
UITextField *textfield;
UITableView *tableView1;
NSMutableArray *_data;
}
#property (nonatomic, retain) NSMutableArray *_data;
- (void) showAlertView;
- (void) doAlertViewWithTextView;
- (void) doAlertViewWithTableView;
#end
and in your imlpementation(.m) file paste this code.
#import "aaViewController.h"
#implementation aaViewController
#synthesize _data;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
self._data = [NSMutableArray arrayWithObjects:#"Najeeb", #"Furqan", #"Khalid", nil];
[self doAlertViewWithTableView];
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return YES;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
- (void) doAlertViewWithTextView {
UIAlertView *alert = [[UIAlertView alloc] initWithFrame:CGRectMake(0, 0, 300, 550)];
alert.title = #"Textview";
alert.message = #"I am doing cool stuff\n\n\n";
alert.delegate = self;
[alert addButtonWithTitle:#"Cancel"];
[alert addButtonWithTitle:#"OK"];
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(12, 90, 260, 200)];
textView.text = #"This is what i am trying to add in alertView.\nHappy New Year Farmers! The new Winter Fantasy Limited Edition Items have arrived! Enchant your orchard with a Icy Peach Tree, and be the first farmer among your friends to have the Frosty Fairy Horse. Don't forget that the Mystery Game has been refreshed with a new Winter Fantasy Animal theme! ";
textView.keyboardAppearance = UIKeyboardAppearanceAlert;
[alert addSubview:textView];
[textView release];
[alert show];
[alert release];
}
- (void) doAlertViewWithTableView {
NSLog(#"Now play with TableView \n%#", self._data);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Table View" message:nil delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"OK", nil];
tableView1 = [[[UITableView alloc] initWithFrame:CGRectMake(10, 40, 264, 200) style:UITableViewStyleGrouped] autorelease];
tableView1.dataSource = self;
tableView1.delegate = self;
[alert addSubview:tableView1];
[alert show];
[alert release];
}
//#define kTag_EnterNameAlert 1
//#define kTag_NameEmtryField 100
- (void) showAlertView {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Congratulations!"
message:#"You earned a top score! Enter your name:\n\n"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:#"OK", nil];
//alert.tag = kTag_EnterNameAlert;
CGRect entryFieldRect = CGRectZero;
if( UIDeviceOrientationIsPortrait( [UIApplication sharedApplication].statusBarOrientation ) ) {
entryFieldRect = CGRectMake(12, 90, 260, 25);
}
else {
entryFieldRect = CGRectMake(12, 72, 260, 25);
}
textfield = [[UITextField alloc] initWithFrame:entryFieldRect];
//textfield.tag = kTag_NameEmtryField;
textfield.backgroundColor = [UIColor whiteColor];
textfield.keyboardType = UIKeyboardTypeAlphabet;
textfield.keyboardAppearance = UIKeyboardAppearanceAlert;
textfield.autocorrectionType = UITextAutocorrectionTypeNo;
textfield.clearButtonMode = UITextFieldViewModeWhileEditing;
[alert addSubview:textfield];
[textfield becomeFirstResponder];
[textfield release];
[alert show];
[alert release];
}
# pragma -
# pragma alertView frame Methods
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(#"name:%# buttonID:%d",textfield.text,buttonIndex);
if (buttonIndex == 1) {
[self doAlertViewWithWebView];
}
else {
NSLog(#"%#",alertView.message);
}
}
// to set the alertView frame size.
- (void)willPresentAlertView:(UIAlertView *)alertView {
[alertView setFrame:CGRectMake(10, 100, 300, 320)];
for ( UIView *views in [alertView subviews]) {
NSLog(#"%#",views);
if (views.tag == 1 || views.tag == 2) {
[views setFrame:CGRectMake(views.frame.origin.x, views.frame.origin.y+200, views.frame.size.width, views.frame.size.height)];
}
}
}
# pragma -
#pragma mark TableView Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 1) {
return [_data count];
}
else
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString* const SwitchCellID = #"SwitchCell";
UITableViewCell* aCell = [tableView dequeueReusableCellWithIdentifier:SwitchCellID];
if( aCell == nil ) {
aCell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:SwitchCellID] autorelease];
aCell.textLabel.text = [NSString stringWithFormat:#"Option %d", [indexPath row] + 1];
aCell.selectionStyle = UITableViewCellSelectionStyleNone;
UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero];
switchView.tag = [indexPath row]+1;
aCell.accessoryView = switchView;
[switchView setOn:YES animated:NO];
[switchView addTarget:self action:#selector(soundSwitched:) forControlEvents:UIControlEventValueChanged];
[switchView release];
}
return aCell;
}
- (void) soundSwitched:(UISwitch*) switchView {
if (!switchView.on) {
NSLog(#"chal bhag %d", switchView.tag);
}
}
#end
Note: In your AppDelegate add as subView to this.

Warning on Alertview [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
warning: 'UIAlertView' may not respond to '-addTextFieldWithValue:label:'
I am using below code for put textfield in AlertView, it gives a warning like "UIAlertView may not respond - addTextFieldWithValue: label:" & "UIAlertView may not respond - textFieldAtIndex"...
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Email" message:#""
delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"Submit", nil];
[alert addTextFieldWithValue:#"" label:#"Email"];
// Username
textfieldName = [alert textFieldAtIndex:0];
textfieldName.keyboardType = UIKeyboardTypeEmailAddress;
textfieldName.keyboardAppearance = UIKeyboardAppearanceAlert;
textfieldName.autocorrectionType = UITextAutocorrectionTypeNo;
[alert show];
please help!
there is no method "addTextFieldWithValue" for uialertview
if you need to modify your alert view have a look at my blog here - http://www.makebetterthings.com/blogs/iphone/add-uitextfield-in-uialertview/
These is no such methods like addTextFieldWithValue in UIAlertView.
[alert addTextFieldWithValue:#"" label:#"Email"]; is a private api. My app got rejected because of using this.
Use this
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:#"Twitter"
message:#"\n\n\n\n"
delegate:self
cancelButtonTitle:#""
otherButtonTitles:#"", nil];
myAlert.frame = CGRectMake( 0, 0, 300, 260);
textfieldName = [[UITextField alloc] initWithFrame:CGRectMake(13, 95, 260, 25.0)];
[textfieldName setBackgroundColor:[UIColor whiteColor]];
textfieldName.placeholder = #"xyz";
textfieldName.keyboardType = UIKeyboardTypeAlphabet;
textfieldName.keyboardAppearance = UIKeyboardAppearanceAlert;
textfieldName.autocorrectionType = UITextAutocorrectionTypeNo;
textfieldName.delegate = self;
textfieldName.tag = 1;
[myAlert addSubview:textfieldName];
**I use in my project < and use and implement
use in .h file**
#protocol InputAlertViewDelegate
-(void)handleEnteredValue:(NSString*)_value;
-(void)handleCancellation;
#end
#interface InputAlertView : UIAlertView <UIAlertViewDelegate> {
UITextField *textField;
id<InputAlertViewDelegate> caller;
} #property(nonatomic, retain) UITextField *textField;
#property(nonatomic, retain) id<InputAlertViewDelegate> caller;
-(NSString*) theText;
-(void) prepare;
-(void) makePassword;
-(void) makeTelephone;
+(InputAlertView*) inputAlertViewWithTitle:(NSString*)_title initialFieldText:(NSString*)_text caller:(id<InputAlertViewDelegate>)_caller;
**use in .m file**
+(InputAlertView*) inputAlertViewWithTitle:(NSString*)_title initialFieldText:(NSString*)_text
caller:(id<InputAlertViewDelegate>)_caller
{
InputAlertView *_alert =
[[[self alloc] initWithTitle:_title message:#"\n" delegate:nil cancelButtonTitle:#"Cancel" otherButtonTitles:#"OK", nil] autorelease];
_alert.delegate = _alert;
_alert.caller = _caller;
[_alert prepare];
_alert.textField.text = _text;
return _alert;
}
-(void)prepare
{
self.textField = [[[UITextField alloc] initWithFrame:CGRectMake(12.0, 45, 260.0, 30.0)] autorelease];
[textField setBackgroundColor:[UIColor clearColor]];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
[self addSubview:textField];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 130.0);
[self setTransform:myTransform];
-(void) show{
[textField becomeFirstResponder];
[super show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex == 1){ [self.caller handleCancellation];
} else{
[self.caller handleEnteredValue:[self theText]];
}
}

How Can I Get Rid Of This Warning?

I'm getting a warning at line (theTextField.delegate = self;) that says "Assigning to 'id from incompatible type Alert Prompt"
- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle okButtonTitle:(NSString *)okayButtonTitle
{
if (self == [super initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:okayButtonTitle, nil])
{
UITextField *theTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[theTextField setBackgroundColor:[UIColor whiteColor]];
[self addSubview:theTextField];
self.textField = theTextField;
[theTextField release];
CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, -25.0);
[self setTransform:translate];
theTextField.backgroundColor = [UIColor clearColor];
theTextField.borderStyle = UITextBorderStyleRoundedRect;
theTextField.delegate = self;
}
return self;
}
About this property in the docs
#property(nonatomic, assign) id<UITextFieldDelegate> delegate
It means, your class must conform to UITextFieldDelegate protocol.
Declaration could look like this
#interface MyController : NSObject <UITextFieldDelegate> {
Try with below code and let me know if you still get the same warning.
- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle okButtonTitle:(NSString *)okayButtonTitle
{
if (self == [super initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:okayButtonTitle, nil])
{
UITextField *theTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[theTextField setBackgroundColor:[UIColor whiteColor]];
theTextField.backgroundColor = [UIColor clearColor];
theTextField.borderStyle = UITextBorderStyleRoundedRect;
theTextField.delegate = self;
self.textField = theTextField;
[theTextField release];
[self addSubview:textField ];
CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, -25.0);
[self setTransform:translate];
}
return self;
}
Also check whether your class confirm with UITextFieldDelegate protocol.

my next view is not displayed when i selected index in tableview & after that i want to go in next view

#import "PantryLocator.h"
#import "RootViewController.h"
#import "CustomView.h"
#import "PantriesViewController.h"
#import "LafoodbankAppDelegate.h"
#implementation PantryLocator
#synthesize mymapView , activityIndicator , indexRow , cityName , customButton;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[self setCityName];
[super viewDidLoad];
}
-(void)setCityName
{
app5 = (LafoodbankAppDelegate *)[[UIApplication sharedApplication] delegate];
pantryDetail = [app5.cities objectAtIndex:indexRow];
cityName.frame = CGRectMake(80, 240, 150, 15);
[cityName setTitle:pantryDetail.cityName forState:UIControlStateNormal];
//[self setCustomButton];
}
/*-(void)setCustomButton
{
//To set custom button
customButton = [UIButton buttonWithType:UIButtonTypeCustom];
[customButton setImage:[UIImage imageNamed:#"go-button-green.png"] forState:UIControlStateNormal];
[customButton addTarget:self action:#selector(goOnPantriesViewController:) forControlEvents:UIControlEventTouchUpInside];
[customButton setFrame:CGRectMake(272, 239, 20, 21)];
[self.view addSubview:customButton];
}*/
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
[textField release];
return YES;
}
-(IBAction)backHome:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
-(IBAction)selectCity:(id)sender
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] init];
[actionSheet showInView:self.view];
actionSheet.frame = CGRectMake(0,225,320,200);
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
CustomView *myView = [[CustomView alloc]initWithNibName:#"CustomView" bundle:nil];
[actionSheet addSubview:myView.view];
[actionSheet release];
//myView.view.frame = CGRectMake(0, 0, 320,100);
//[myView release];
/*UIPickerView *pickerView = [[UIPickerView alloc]initWithFrame:CGRectMake(0, 40, 0, 0)];
pickerView.showsSelectionIndicator = YES;
pickerView.delegate = self;
pickerView.dataSource = self;
[actionSheet addSubview:pickerView];
[pickerView release];
[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
//[actionSheet release];*/
}
-(IBAction)parsingCity:(id)sender
{
//Reading file from URL
NSURL *url = [[NSURL alloc]initWithString:#"http://www.lafoodbank.org/pantry-xml.aspx?city=all"];
NSData *data = [[NSData alloc]initWithContentsOfURL:url];
//Parsing
parser = [[PantryParser alloc]init];
[parser parseXML:data];
[data release];
}
-(IBAction)goOnPantriesViewController:(id)sender
{
PantriesViewController *pantriesViewController = [[PantriesViewController alloc]initWithNibName:#"PantriesViewController" bundle:nil];
[self.navigationController pushViewController:pantriesViewController animated:YES];
[pantriesViewController release];
}
-(IBAction)goToDesignsite:(id)sender
{
DesignWebView *designWebView = [[DesignWebView alloc]initWithNibName:#"DesignWebView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:designWebView animated:YES];
[designWebView release];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (void)dealloc
{
[super dealloc];
}
#end
In above code i am confused that i am not go to next view when i select a particular city in setCityName so please give me solution.....
Instead of
UIActionSheet *actionSheet = [[UIActionSheet alloc] init];
Try This.
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:#"Your Title" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
Hope it helps.
hi friend
Go to your nib file and add method to your button first