我想在UITableView中编辑用户的用户名.我在UITableViewCell中添加了一个UITextField,这看起来效果非常好.但是当用户触摸单元格时(甚至在文本区域外),他希望编辑.
我如何以编程方式选择文本字段?
代码看起来像:
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
userName.selected = TRUE;
}
Run Code Online (Sandbox Code Playgroud) 我想使用可靠的位置,即使在旧的iPhone上也是如此.然而,许多读数(特别是来自手机信号塔)的读数太不准确.我认为.
当我绘制我的位置+精确度半径(或查看谷歌地图应用程序)时,我注意到估计圆圈的中心通常接近我的物理位置.我猜测,如果我将"准确度"数字减半,我仍然会在99%的时间内处于圆圈状态.
我相信这是一个概率性游戏 - 位置经理试图提供99.99999%的正确估计值,因此他们故意给出了大量的余量.任何想法/信息?
我想在启动时使用模态UITableView来询问用户密码等,如果它们尚未配置.但是,调用uitableview的命令似乎在viewDidLoad中不起作用.
启动代码:
- (void)viewDidLoad {
rootViewController = [[SettingsController alloc]
initWithStyle:UITableViewStyleGrouped];
navigationController = [[UINavigationController alloc]
initWithRootViewController:rootViewController];
// place where code doesn't work
//[self presentModalViewController:navigationController animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
但是,稍后通过按钮调用时,相同的代码可以正常工作:
- (IBAction)settingsPressed:(id)sender{
[self presentModalViewController:navigationController animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
相关问题:当UITableView使用命令退出时,我如何感知(在上层)?
[self.parentViewController dismissModalViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中的地图上显示一些图标(注释),方法是将它们加载到NSMutableArray中,然后添加数组.它运行良好,但我无法以适当的层次顺序显示它们.
有时,我添加到positionIcons的图标最后显示在顶部; 其他时候,最新的显示在较旧的下面.
如何确保图层顺序?
[positionIcons removeAllObjects];
[positionIcons insertObject:<someObject> atIndex:0];
[mapView addAnnotations:positionIcons];
Run Code Online (Sandbox Code Playgroud) 我收到错误"[myObject method]:消息发送到解除分配的实例0xbc05440".这一定是因为我发布了一些我仍然需要的东西.
我寻找适当的nils,release等,但我无法找到释放此对象的位置.
然后我在myObject的dealloc中放置了一个休息时间.这会捕获dealloc,但堆栈只显示汇编代码.如果我从这个地方走,我没有得到任何提示.如何找到dealloc的起始位置?
在为我的一个对象赋值时,我遇到了一个奇怪的错误.尽我所知,编译器认为我正在分配一个只读变量.它在myPlace.publicLocation ...行上给出了"作为赋值的左操作数所需的左值".
我确定这是一个经典的新手错误 - 我哪里错了?
CSPlace *myPlace;
myPlace.publicLocation.coordinate.latitude =
[[separatedData objectAtIndex:0] floatValue];
Run Code Online (Sandbox Code Playgroud)
类:
#import <CoreLocation/CLLocation.h>
@interface CSPlace : NSObject {
CLLocation *publicLocation;
}
@property (copy, nonatomic) CLLocation *publicLocation;
@end
#import "CSPlace.h"
@implementation CSPlace
@synthesize publicLocation;
@end
Run Code Online (Sandbox Code Playgroud) 我不希望我的应用程序进入睡眠状态(关闭屏幕),除非用户将其从痛苦中解脱出来.我正在尝试我认为简单的代码:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
application.idleTimerDisabled = YES;
Run Code Online (Sandbox Code Playgroud)
这大部分时间都可以使用,但应用程序偶尔会进入睡眠状态.我不确定这个模式.有没有可以重新启用空闲计时器的东西?
当用户点击设置按钮时,我的应用程序会弹出一个uitableview屏幕.我无法弄清楚如何通过动作连接请求解除.
如何从uitableview中忽略此视图?
设置视图:
SettingsController *rootViewController = [[SettingsController alloc]
initWithStyle:UITableViewStyleGrouped];
UINavigationController *navigationController = [[UINavigationController alloc]
initWithRootViewController:rootViewController];
settingsView = navigationController.view;
settingsView.frame =
CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[self.view insertSubview:settingsView atIndex:0];
Run Code Online (Sandbox Code Playgroud)
将观点带到前面:
- (IBAction)settingsPressed:(id)sender{
[self.view bringSubviewToFront:settingsView];
}
Run Code Online (Sandbox Code Playgroud)
将视图放在后面:
- (void)QuitSettings {
[self.view sendSubviewToBack:settingsView];
}
Run Code Online (Sandbox Code Playgroud)
在SettingsController中单击"返回"按钮:
- (void) action:(id) sender{
//[super.view sendSubviewToBack:holdingView];
// access error [self release];
// nothing [holdingView removeFromSuperview];
// access error [super QuitSettings];
}
Run Code Online (Sandbox Code Playgroud) 我有一些代码,我认为有额外的发布声明.
我还不太了解内存管理 - 即使在阅读了大量文章和stackoverflow答案之后.谢谢你把我拉直了.
更新:附加的代码段工作正常,但其他代码有过度释放问题
NSMutableArray *points = [NSMutableArray new];
for (Segment *s in currentWorkout.segments) {
[points addObjectsFromArray:[s.track locationPoints]];
}
[routeMap update:points];
[points release];
Run Code Online (Sandbox Code Playgroud) Core Data在我的应用程序中运行得相当顺利.我可以存储和检索所需的大部分数据.然而,
ObjectW和ObjectX都存储在ObjectY中.两者都没有显式调用awakeFromFetch,只是对某些属性的引用.
- (void) awakeFromInsert {
[super awakeFromInsert];
}
- (void) awakeFromFetch {
NSLog(@"AWAKE FROM FETCH");
[super awakeFromFetch];
}
Run Code Online (Sandbox Code Playgroud)
有些不对劲.我在哪里看?
我正在试图通过Obj-C来构建一款iPhone游戏.
我想构建一个对象数组供以后使用.这是我试过的:
NSMutableArray *positionIcons;
[positionIcons insertObject:annotation atIndex:0];
positionIcons = [NSArray arrayWithObjects:annotation, nil];
Run Code Online (Sandbox Code Playgroud)
insertObject行将计数保留为0.但是,下一行正确插入对象(并且计数移动到1).是什么赋予了?