NSString从NSMutableArrayObjective-C中删除重复值()的最佳方法是什么?
这是最简单正确的方法吗?
uniquearray = [[NSSet setWithArray:yourarray] allObjects];
Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,我将内容加载到一个UIWebView并呈现此.我无法完全禁用用户交互,因为我希望用户能够单击链接.我只需要禁用用户选择.我发现你可以使用的互联网中的某个地方:
document.body.style.webkitUserSelect='none';
Run Code Online (Sandbox Code Playgroud)
我试着插入这个
[self.contentView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitUserSelect='none';"];
Run Code Online (Sandbox Code Playgroud)
在 webViewDidFinishLoad:
但是,它不起作用.我仍然可以在WebView中选择和复制文本.
什么想法可能会出错?
更新:这似乎只从iOS 4.3开始
我有一个ViewController在里面UINavigationcontroller,但导航栏是隐藏的.当我在iOS 7上运行应用程序时,状态栏显示在我的视图之上.有办法避免这种情况吗?
我不想编写任何特定于操作系统的代码.

我试着设置View controller-based status bar appearance到NO,但它并没有解决这个问题.
作为一种学习体验,我想创建一个调用webserver/webservice的iPhone应用程序,检索JSON响应,并使用该响应填充a的行UITableView(假设它将JSON转换为NSArray第一个).
有人知道任何可能有用的东西吗?
我不确定我做错了什么,但我试图抓住一个MKMapView物体.我通过创建以下类来继承它:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface MapViewWithTouches : MKMapView {
}
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *) event;
@end
Run Code Online (Sandbox Code Playgroud)
并实施:
#import "MapViewWithTouches.h"
@implementation MapViewWithTouches
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *) event {
NSLog(@"hello");
//[super touchesBegan:touches withEvent:event];
}
@end
Run Code Online (Sandbox Code Playgroud)
但看起来当我使用这个类时,我在控制台上看不到任何内容:
MapViewWithTouches *mapView = [[MapViewWithTouches alloc] initWithFrame:self.view.frame];
[self.view insertSubview:mapView atIndex:0];
Run Code Online (Sandbox Code Playgroud)
知道我做错了什么吗?
我正在尝试使用上传文件Alamofire.使用File(NSUrl)时上传工作正常,但是,我似乎无法弄清楚如何使用该NSData选项?
这就是我的测试:
var url:NSURL = NSURL.URLWithString("http://localhost:8080/bike.jpeg")
var err: NSError?
var imageData :NSData = NSData.dataWithContentsOfURL(url,options: NSDataReadingOptions.DataReadingMappedIfSafe, error: &err)
Alamofire.upload(.POST, "http://localhost:8080/rest/service/upload/test.png", imageData)
.progress { (bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) in
println(totalBytesWritten)
}
.responseJSON { (request, response, JSON, error) in
println(request)
println(response)
println(JSON)
}
Run Code Online (Sandbox Code Playgroud)
我收到状态代码415?
另外,如何在上传中发送其他参数?
谢谢
编辑
我没有设置正确的内容类型:
var manager = Manager.sharedInstance
manager.session.configuration.HTTPAdditionalHeaders = ["Content-Type": "application/octet-stream"]
let imageData: NSMutableData = NSMutableData.dataWithData(UIImageJPEGRepresentation(imageTest.image, 30));
Alamofire.upload(.POST, "http://localhost:8080/rest/service/upload?attachmentName=file.jpg", imageData)
.progress { (bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) in
println(totalBytesWritten)
}
.responseString { (request, response, JSON, …Run Code Online (Sandbox Code Playgroud) 嗨,我需要在导航栏中以编程方式设置右侧的按钮,这样如果我按下按钮,我将执行一些操作.我以编程方式创建了导航栏;
navBar=[[UINavigationBar alloc]initWithFrame:CGRectMake(0,0,320,44) ];
Run Code Online (Sandbox Code Playgroud)
同样,我需要在此导航栏的右侧添加按钮.为此我用过,
1.
UIView* container = [[UIView alloc] init];
// create a button and add it to the container
UIButton* button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 130, 44.01)];
[container addSubview:button];
[button release];
// add another button
button = [[UIButton alloc] initWithFrame:CGRectMake(160, 0, 50, 44.01)];
[container addSubview:button];
[button release];
// now create a Bar button item
UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithCustomView:container];
// set the nav bar's right button item
self.navigationItem.rightBarButtonItem = item;
[item release];
Run Code Online (Sandbox Code Playgroud)
2. …
由于CoreData已经可以在OS 3.0中用于iPhone,它是否意味着数据持久性的答案并取代所有直接需求SQLite?
还有什么理由可以使用SQLite?什么是SQLitevs.的优点/缺点CoreData?
所以现在我有一个UIView与UILabel它.我希望背景的不透明度<1.0,标签的不透明度为1.0.但是,由于alphas在视图层次结构中向下传播,因此标签最终的不透明度<1.0.
反正有没有做我想要的而不做UILabel另一个视图的子视图?
我有一个UIScrollView实现takeScreenshot方法的decedent,如下所示:
-(void)takeScreenshot {
CGRect contextRect = CGRectMake(0, 0, 768, 1004);
UIGraphicsBeginImageContext(contextRect.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// do something with the viewImage here.
}
Run Code Online (Sandbox Code Playgroud)
这基本上移动到滚动视图的顶部,并截取可见区域的屏幕截图.当iPad面向人像时,它可以正常工作,但当它处于横向时,图像的底部会被切断(因为可见区域的高度仅为748,而不是1004).
是否有可能获得快照UIScrollView,包括不在屏幕上的区域?或者我需要向下滚动视图,拍摄第二张照片并将它们拼接在一起?