我正在寻找一种防止删除我的一个细胞的方法.(当表格视图处于编辑模式时,单元格旁边不会出现删除按钮.)
怎么能成为可能呢?
我想知道为什么我的UINavigationController不让我设置标题.它允许我改变navigationBar的色调,但我设置的标题和rightBarButtonItem被忽略.为什么?
这是我的代码:
taps = 0;
UIView*controllerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
controllerView.backgroundColor = [UIColor whiteColor];
controller = [[UIViewController alloc] init];
[controller setView:controllerView];
[controllerView release];
navController = [[UINavigationController alloc] initWithRootViewController:controller];
navController.navigationBar.barStyle = 1;
navController.navigationItem.title = @"Setup";
UIBarButtonItem*item = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonSystemItemDone target:self action:@selector(dismissSetup:)];
navController.navigationItem.rightBarButtonItem = item;
[item release];
[self presentModalViewController:navController animated:YES];
[mp stop];
Run Code Online (Sandbox Code Playgroud)
ps:我知道我没有发布我分配的一些东西,我以后再这样做!
我有一个NSScanner对象,扫描HTML文档中的段落标记.看起来扫描仪停在它找到的第一个结果,但我需要一个数组中的所有结果.
如何改进我的代码以完成整个文档?
- (NSArray *)getParagraphs:(NSString *) html
{
NSScanner *theScanner;
NSString *text = nil;
theScanner = [NSScanner scannerWithString: html];
NSMutableArray*paragraphs = [[NSMutableArray alloc] init];
// find start of tag
[theScanner scanUpToString: @"<p>" intoString: NULL];
if ([theScanner isAtEnd] == NO) {
NSInteger newLoc = [theScanner scanLocation] + 10;
[theScanner setScanLocation: newLoc];
// find end of tag
[theScanner scanUpToString: @"</p>" intoString: &text];
[paragraphs addObject:text];
}
return text;
}
Run Code Online (Sandbox Code Playgroud) 我正在创建一个NSCell子类,它将一些对象直接绘制到视图上(使用drawInRect:fromRect:operation:fraction:respectFlipped:hints:),并且还NSButton使用NSView的addSubview:选择器绘制一个实例.
虽然使用第一种方法绘制的对象都是相关的,但是我在绘制NSButton正确的方法时遇到了问题.问题是我的NSButton实例会在正确的位置绘制,但多次覆盖.
我已经在互联网上研究了一段时间,有些人建议使用缓存,但我不确定这是否有效.(使用for循环包含按钮的数组肯定会导致慢滚动,因为我显示了大量数据...)
你会怎么做?我吠叫错了树吗?
这是相关代码:
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
NSRect _controlRect = cellFrame;
float _Y = cellFrame.origin.y;
NSRect _accessoryRect = NSMakeRect(_controlRect.size.width - 70.0f, _Y + 9.0f, 50.0f, 23.0f);
_switch = [self _choiceSwitch];
[_switch setFrame:_accessoryRect];
[controlView addSubview:_switch];
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试从互联网上下载文件,但我收到了错误-3001.我一直在搜索谷歌,但错误没有出现在任何网站上,所以我不知道这意味着什么.
谁能告诉我错误代码的"NSURLErrorDomain error -3001"含义?
谢谢
我正在尝试使用POST请求将多个文件上传到服务器,但由于某种原因,只提交了一个文件.我怀疑我做错了边界,但我不知道在哪里......
我的代码出了什么问题?
[_serverRequest setHTTPMethod:@"POST"];
NSString *_boundary = @"14737809831466499882746641449";
NSString *_contentType = [NSString stringWithFormat:@"multipart/form-data; charset=UTF-8; boundary=%@",_boundary];
[_serverRequest setValue:_contentType forHTTPHeaderField:@"Content-Type"];
/* reqeuest body */
NSMutableData *_requestBody = [NSMutableData data];
for (id _instance in self.currentBrowserInstances)
{
if ([_instance respondsToSelector:@selector(pathToDatabase)])
{
NSString *_databasePath = [_instance pathToDatabase];
NSMutableString *_filename = [NSMutableString stringWithString:[self _generatedFilename]];
[_filename appendFormat:@"_%@", [[_instance name] stringByReplacingOccurrencesOfString:@" " withString:@""]];
if (_databasePath.pathExtension.length > 0)
[_filename appendFormat:@".%@", _databasePath.pathExtension];
/* Build Request Body */
[_requestBody appendData:[[NSString stringWithFormat:@"--%@\r\n", _boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[_requestBody appendData:[[NSString stringWithFormat:@"Content-Disposition: multipart/form-data; name=\"databases\"; filename=\"%@\"\r\n", …Run Code Online (Sandbox Code Playgroud) 我已经开发了许多框架,我希望随我的应用程序一起提供.我不希望其他人能够使用框架,但我已经看到了诸如class-dump可以轻松恢复标头的实用程序.
我的问题是,如何让我的框架更安全?我知道他们永远不会100%安全,但有一些很好的一般提示可以遵循吗?
谢谢!
我正在尝试在iOS设备和Mac之间建立Bonjour连接.发现彼此工作很好,但我遇到了问题setTXTRecordData:.它总是失败(BOOL返回NO)......
_serviceInstances创建:
-(void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didFindService:(NSNetService *)aNetService moreComing:(BOOL)moreComing
{
[aNetService retain];
[aNetService setDelegate:self];
[aNetService startMonitoring];
[aNetService performSelectorOnMainThread:@selector(resolve) withObject:nil waitUntilDone:YES];
[_serviceInstances addObject:aNetService];
}
Run Code Online (Sandbox Code Playgroud)
发送尝试:
NSNetService*service = [_serviceInstances objectAtIndex:[servicesTable selectedRow]];
[service setDelegate:self];
NSDictionary*txtRecordDataDictionary = [NSDictionary dictionaryWithObject:@"2" forKey:@"Version"];
if (service)
{
BOOL success = [service setTXTRecordData:[NSNetService dataFromTXTRecordDictionary:txtRecordDataDictionary]];
if (!success)
{
NSRunCriticalAlertPanel(@"Sync Error", @"Failed to contact Client. Please restart Carbon on your iPad and try again.", @"OK", nil, nil);
}
NSLog(@"Service: %@",service);
}
Run Code Online (Sandbox Code Playgroud)
NSLog消息输出Service: <NSNetService 0x441b40> local. _test._tcp. David's iPad正确.
iOS代码: …
objective-c ×6
iphone ×3
bonjour ×1
cocoa ×1
cocoa-touch ×1
frameworks ×1
ios ×1
macos ×1
nscell ×1
nserror ×1
nsscanner ×1
nstableview ×1
nsurlrequest ×1
uikit ×1
uitableview ×1