我正在开发一个iPhone应用程序,其中我想根据当前位置显示最近的餐馆为此在applicationDidFinishLaunching我这样做:
self.locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
NSURL *url = [[NSURL alloc] initWithString:@"http://192.168.0.150/server1/Service.asmx/nearest?lat1=23.013163&lon1=72.559068"];
NSMutableURLRequest* request2=[NSMutableURLRequest requestWithURL:url];
[request2 setHTTPMethod:@"GET"];
[request2 setTimeoutInterval:10];
NSURLResponse *response=nil;
NSError *err=nil;
NSData *data1=[[NSURLConnection sendSynchronousRequest:request2 returningResponse:&response error:&err] retain];
if(data1 == nil)
{
UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"The network is not available.\n Please check the Internet connection." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
else
{
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:data1];
//Initialize the delegate.
XMLParser *parser = [[XMLParser alloc] …Run Code Online (Sandbox Code Playgroud) 我有一个生成礼品代码的后端,每个代码都有一定数量的用途.将这些内容提供给博客或其他任何人,他们的读者可以兑换促销项目的代码.
我正在研究检查代码有效性的最佳方法,而不会发生碰撞/欺骗,或类似的事情.我需要1)验证代码2)收集运输信息
我的初稿是
A)通过表格检查代码,如果好,继续进行地址输入.收到输入后,保存代码和地址/名称等.
这失败了,因为如果75使用代码有74次使用,25人可以"验证"但尚未输入他们的地址,我们最终会有超过75次有效兑换.
我目前的解决方案看起来更像:
B)只需将代码作为信息收集表单中的第一个字段,并在输入有效代码时,ajaxify并对数据库进行实时检查.如果代码有效,则会显示表单的其余部分,并且代码的条目被"声明"半小时或其他内容.如果半小时内没有数据库条目,则会释放.
这看起来相当复杂,我想知道我是否需要对ajax进行限制,以确保人们不会强行执行有效的代码.
这种方法是否安全,和/或是否有任何其他明显的模式我缺少这种类型的应用程序?
这两者有什么区别?
@property (nonatomic, retain)
@property (nonatomic, copy)
Run Code Online (Sandbox Code Playgroud)
这样的其他类型是什么?
我想在程序开头加载第二个View.我想,viewDidLoad-methode将是正确的方法.问题是它不起作用.
我想在viewDidLoad方法中加载视图的原因是,在新设备(iPad)上可以在另一个视图上加载视图.
我该怎么做?我试过这个,但它不起作用:
- (void)viewDidLoad {
StartViewController * start = [[StartViewController alloc]initWithNibName:nil bundle:nil];
start.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
start.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:start animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
我尝试了addSubview并且它可以工作,但后来我没有很好的过渡.任何的想法?我也试过awakeFromNib.这也不是关于iPad的问题,所以我不打破nda.这是一个普遍的问题,如何在viewDidLoad方法(或其他方法)中加载新视图.

我正在构建一个包含三个部分的tableView.我有前两个工作,但最后一个有点抵抗.我的问题似乎涉及尝试在switch语句中声明一个变量,实际上是一个嵌套的switch语句.从我所读到的,这不是一个好主意,但在这种情况下,它似乎是唯一的选择.
有问题的部分动态地容纳与特定设备相关联的Alert对象的数量.警报来自核心数据,代替"日期"和"警报消息"我想显示警报中的信息.我正在使用NSFetchRequest检索相关警报.返回一个Alert对象数组,按照我想要的方式排序.要在cellForRowAtIndexPath中显示正确的信息,我一直试图使用该行恢复正确的警报
Alert *alert = [allAlerts objectAtIndex:indexPath.row];
Run Code Online (Sandbox Code Playgroud)
似乎我不允许在switch语句中声明变量.我有什么想法可以解决这个问题吗?我将不得不在didSelectRowForIndexPath中做类似的事情,因为我需要在选择单元格时推送详细视图.
我已经尝试在switch语句之外声明变量,但这不会起作用,因为index.row可以在Alert数组中不存在的索引中请求一个对象,并且会导致程序崩溃.
有问题的代码位于此方法的底部:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//Cell Identifiers
static NSString *attributeCellIdentifier = @"attributeCellIdentifier";
static NSString *operatingInfoCellIdentifier = @"operatingInfoCellIdentifier";
static NSString *alertCellIdentifier = @"alertCellIdentifier";
//Create Attribute Cell If Required
UITableViewCell *attributeCell = [tableView dequeueReusableCellWithIdentifier:attributeCellIdentifier];
if (attributeCell == nil) {
attributeCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:attributeCellIdentifier] autorelease];
attributeCell.selectionStyle = UITableViewCellSelectionStyleNone;
}
//Create Operating Info Cell If Required
UITableViewCell *operatingInfoCell = [tableView dequeueReusableCellWithIdentifier:operatingInfoCellIdentifier];
if (operatingInfoCell == nil) {
operatingInfoCell = [[[UITableViewCell alloc] …Run Code Online (Sandbox Code Playgroud) 当我在iPhone上安装我的应用程序时,它会在警报中询问"不允许"和"确定"选项的当前位置.如何找出选择的选项?我也想只显示一次此选项.如果用户选择允许找到他们当前的位置,我希望设备自动获取后台位置.
小伙子们,
我正在开发一个应用程序,其中我需要多次向用户询问其位置的功能,当用户允许一次使用他的位置时会发生什么,当他导航到另一个部分时,它不会要求他获取他的位置,它正在采取它来自已经缓存的位置.
是否有可能要求用户多次获得他的批准才能获得他的位置?
任何帮助赞赏.
干杯,阿米特
如何将(id)发件人添加到以下代码?
- (IBAction) gobutton: (UIButton *) button5 {
Run Code Online (Sandbox Code Playgroud)
我尝试的一切都失败了,任何帮助都会受到赞赏.谢谢.
编辑:我需要在(IBAction)中保留(UIButton*)按钮5参考
iphone objective-c uibutton iphone-sdk-3.0 cocoa-design-patterns
iphone ×6
objective-c ×3
core-data ×1
ios ×1
properties ×1
security ×1
uibutton ×1
uitableview ×1