似乎在Xcode 8上viewDidLoad,所有viewcontroller子视图都具有相同的1000x1000大小.奇怪的是,但没关系,viewDidLoad从来没有一个正确调整视图大小的好地方.
但是viewDidLayoutSubviews!
在我当前的项目中,我尝试打印按钮的大小:
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
NSLog(@"%@", self.myButton);
}
Run Code Online (Sandbox Code Playgroud)
日志显示myButton的大小为(1000x1000)!然后,如果我登录按钮单击,例如,日志显示正常大小.
我正在使用autolayout.
这是一个错误吗?
我目前正在使用Graph API Explorer进行一些测试.这是一个很好的工具.
我想获取用户的朋友列表,包括朋友的姓名,ID和图片.所以我键入:
https://graph.facebook.com/me/friends?fields=id,picture,name
Run Code Online (Sandbox Code Playgroud)
但是图片只有50x50,我希望在这个请求中有一个更大的图片.
可能吗 ?
我刚刚安装了新版本的Xcode/ios6.viewDidUnload现在已折旧.
在苹果文档中,
viewDidUnload [...]在iOS 6.0中已弃用.在低内存条件下不再清除视图,因此永远不会调用此方法.
但是大量的应用程序正在使用此回调来释放其属性,例如:
- (void)viewDidUnload {
[super viewDidUnload];
self.recipientButton = nil;
self.connectButton = nil;
self.infoLabel = nil;
}
Run Code Online (Sandbox Code Playgroud)
这是发布IBOutlets的最佳做法.
那么,第一个问题:
iOS 6中这些现有应用程序会发生什么?他们会泄漏吗?
第二个:
发布IBOutlet属性的新推荐方法是什么?在dealloc方法?
即使Apple没有参加Barcelone的MWC(移动世界大会),也有人认为获得deviceID将在其他iOS SDK中弃用.
我不明白Apple为什么要限制这个,但那不是主题.
我必须准备我的应用程序,因为我的用户已被识别并且知道更好地使用我的应用程序(例如,不需要登录或创建帐户).而且我确信在那种情况下我并不孤单.
所以有人知道获取deviceID的替代方案吗?是否有其他唯一标识符,例如MAC地址?你如何准备你的应用程序?
我创建了一个基于导航的应用程序模板的iOS应用程序,该应用程序由Core Data框架支持.
单击"编辑"按钮时,我希望行可以重新排序并且可以删除.
在构建单元格时,我添加了这一行:
cell.showsReorderControl = YES;
Run Code Online (Sandbox Code Playgroud)
和tableView:canMoveRowAtIndexPath:方法返回YES.
但重新排序控件没有显示在行中,我错过了什么?
我的文档目录中有一个巨大的文件树和目录用于缓存.
按照建议,我将NSURLIsExcludedFromBackupKey用于防止iTunes使用该应用程序保存此数据.
我可以在我的根目录URL上使用它一次,如
[rootDirectoryURL setResourceValue:[NSNumber numberWithBool:YES] forKey:@"NSURLIsExcludedFromBackupKey" error:&error];
Run Code Online (Sandbox Code Playgroud)
或者我必须为每个文件调用它吗?
我正在使用 Swift 5.7 新功能,并尝试实现一些异构集。
我已将代码简化为这个简单的游乐场:
protocol Stuff: Hashable {
var identifier: String { get }
}
struct StuffA: Stuff {
let identifier: String
func hash(into hasher: inout Hasher) {
hasher.combine(identifier)
}
}
struct StuffB: Stuff {
let identifier: String
func hash(into hasher: inout Hasher) {
hasher.combine(identifier)
}
}
var arrayOfStuff: Array<any Stuff> = []
arrayOfStuff.append(StuffA(identifier: "a"))
arrayOfStuff.append(StuffB(identifier: "b"))
// Works like a charm
var setOfStuff: Set<any Stuff> = Set()
// error: Type 'any Stuff' cannot conform to 'Hashable'
setOfStuff.insert(StuffA(identifier: "a")) …Run Code Online (Sandbox Code Playgroud) 由于我已经安装了最后一个xCode(我之前的版本是3.xx),因此很难调试崩溃的应用程序.实际上,callstack通常是空的.并且显示的方法是
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"MyAppDelegate");
[pool drain];
return retVal;
}
Run Code Online (Sandbox Code Playgroud)
例如:

有没有人注意到这个?它与以前的XCode在同一个项目上完美配合.有什么解决方案吗?
I'm using AVCaptureSession to capture video.
I want to light on the torch during the whole session, but once the session is started, the light turns automatically off.
这里有很多帖子展示了如何打开手电筒。它有效,除非捕获会话已启动。
这是我开始会话的方式
guard let camera = AVCaptureDevice.default(for: .video) else { return }
self.captureSession.beginConfiguration()
let deviceInput = try AVCaptureDeviceInput(device: camera)
self.captureSession.addInput(deviceInput)
let videoOutput = AVCaptureVideoDataOutput()
videoOutput.setSampleBufferDelegate(self, queue: DispatchQueue(label: "com.axelife.axcapturer.samplebufferdelegate"))
self.captureSession.addOutput(videoOutput)
try camera.setLight(on: true)
self.captureSession.commitConfiguration()
DispatchQueue(label: "capturesession").async {
self.captureSession.startRunning()
}
Run Code Online (Sandbox Code Playgroud)
还有我开灯的代码
extension AVCaptureDevice {
func setLight(on: Bool) throws {
try self.lockForConfiguration()
if …Run Code Online (Sandbox Code Playgroud) 我已经为用户当前位置加载了自定义注释图像.我在后台每1秒后更新当前用户位置.
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[self performSelectorOnMainThread:@selector(tempupdate) withObject:nil waitUntilDone:NO];
[pool release];
-(void)tempupdate
{
NSLog(@"callToLocationManager");
mylocationManager = [[CLLocationManager alloc]init];
NSLog(@"locationManagerM = %@",mylocationManager);
mylocationManager.delegate = self;
mylocationManager.desiredAccuracy = kCLLocationAccuracyBest;
mylocationManager.distanceFilter = 500;
[mylocationManager startUpdatingLocation];
}
Run Code Online (Sandbox Code Playgroud)
更新当前latutude和经度后,我使用以下代码刷新地图
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.002;
span.longitudeDelta=0.002;
CLLocationCoordinate2D location;
location.latitude=[lat doubleValue];
location.longitude=[longt doubleValue];
region.span=span;
region.center=location;
addAnnotation=[[AddressAnnotation alloc]initWithCoordinate:location];
addAnnotation.mTitle=@"You are here";
[self.mapView removeAnnotations:self.mapView.annotations];
[self.mapView addAnnotation:addAnnotation];
[self.mapView setRegion:region animated:TRUE];
[self.mapView regionThatFits:region];
Run Code Online (Sandbox Code Playgroud)
但每次自定义注释图像在添加到地图之前闪烁.如何避免这种闪烁效应?
ios ×5
iphone ×5
swift ×2
autolayout ×1
backup ×1
callstack ×1
cocoa-touch ×1
core-data ×1
deprecated ×1
facebook ×1
generics ×1
ios10 ×1
ios4 ×1
ios6 ×1
mkmapview ×1
objective-c ×1
protocols ×1
uitableview ×1
validation ×1
xcode4.2 ×1
xcode8 ×1