#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
在上面的代码中,我很困惑,当我在setCityName中选择一个特定的城市时,我不会去下一个视图所以请给我解决方案.....
答案 0 :(得分:0)
而不是
UIActionSheet *actionSheet = [[UIActionSheet alloc] init];
试试这个。
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Your Title" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
希望它有所帮助。
答案 1 :(得分:-1)
朋友 转到您的nib文件并首先将方法添加到按钮