是否可以以编程方式更改uitextfield的键盘类型,以便这样的事情可能:
if(user is prompted for numeric input only)
[textField setKeyboardType: @"Number Pad"];
if(user is prompted for alphanumeric input)
[textField setKeyboardType: @"Default"];
Run Code Online (Sandbox Code Playgroud) 我正在尝试动画CALayer从正常角落到圆角的过渡.我只想绕过顶角,所以我使用的是UIBezierPath.这是代码:
UIRectCorner corners = UIRectCornerTopLeft | UIRectCornerTopRight;
UIBezierPath* newPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(8.0f, 8.0f)];
UIBezierPath* oldPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(0.0f, 0.0f)];
CAShapeLayer* layer = [CAShapeLayer layer];
layer.frame = self.bounds;
layer.path = oldPath.CGPath;
self.layer.mask = layer;
CABasicAnimation* a = [CABasicAnimation animationWithKeyPath:@"path"];
[a setDuration:0.4f];
[a setFromValue:(id)layer.path];
[a setToValue:(id)newPath.CGPath];
layer.path = newPath.CGPath;
[layer addAnimation:a forKey:@"path"];
Run Code Online (Sandbox Code Playgroud)
但是当我运行它时,角落是圆形的,但是没有动画 - 它会立即发生.我在这里看到了一些类似的问题,但它们并没有解决我的问题.
我敢肯定,我只是做了一件小问题导致了这个问题,但对于我的生活,我无法理解.
解:
- (void)roundCornersAnimated:(BOOL)animated {
UIRectCorner corners = UIRectCornerTopLeft | UIRectCornerTopRight;
UIBezierPath* newPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(8.0f, 8.0f)];
UIBezierPath* …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我有一个滚动视图和四个表视图.每次拖动然后释放,我都会得到48字节的泄漏.这确实加起来了.如您所见,两组泄漏都具有相同的来源.以前有人见过这样的泄漏吗?


当我点击泄漏旁边的箭头时,我得到了泄漏信息:

我正在尝试使用Interface Builder编译和运行Objective C应用程序的简单教程.我正在使用Xcode 4.0.2并在iOS(iPhone)4.3上进行模拟
当我构建项目时,它构建正常但是一旦应用程序尝试运行它崩溃:
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"SimpleUIAppDelegate");
[pool release];
return retVal;
}
Run Code Online (Sandbox Code Playgroud)
我在第4行得到错误:int retVal = UI ...线程1:程序接收信号"SIGABRT".
如果为了清楚起见需要发布该项目的其他文件,我可以这样做.
谢谢!
编辑:
SimpleUIViewController.h:
#import <UIKit/UIKit.h>
@interface SimpleUIViewController : UIViewController <UITextFieldDelegate> {
UITextField *textInput;
UILabel *label;
NSString *name;
}
@property (nonatomic, retain) IBOutlet UITextField *textInput;
@property (nonatomic, retain) IBOutlet UILabel *label;
@property (nonatomic, copy) NSString *name;
- (IBAction)changeGreeting:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud)
SimpleUIViewController.m:
#import "SimpleUIViewController.h"
@implementation SimpleUIViewController
@synthesize …Run Code Online (Sandbox Code Playgroud) 有人可以向我解释为什么以下代码:
NSString* filePathString = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
NSLog(@"%i", [[NSURL URLWithString:filePathString] isFileURL]);
NSLog(@"%@", filePathString);
Run Code Online (Sandbox Code Playgroud)
输出:
0
"在/ var /移动/应用/ 28ADFC19-874C-4304-94B5-F6441CAE9FAD /文档"
这意味着此网址不是文件网址.显然,它是.
背景:
我正在尝试使用AVCaptureMovieFileOutput将电影录制内容写入文件,但我提供的文件网址提供错误:
*由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:'* - [AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] - 无法记录到URL/var/mobile/Applications/28ADFC19-874C-4304-94B5-F6441CAE9FAD/Documents/media/CrKNjNhe9so2LRnD9iHK .mov因为它不是文件URL.
对我来说,这看起来像一个文件URL,就像原始示例一样.是什么赋予了?
filesystems nsurl nsfilemanager ios avcapturemoviefileoutput
我有一个应用程序,围绕设备的GPS和来自它的信息.重要的是,位置数据必须准确并且是最新的.我知道该设备受到GPS和GPS限制的限制,但我想知道我是否可以采取任何措施来调整/改善iPhone GPS的性能,特别是在速度区域.由于位置更新滞后于设备实时位置约3-5秒,因此位置管理器报告的速度也远远落后于实时值.就我而言,这太长了.我知道可能没有什么我可以做的,但有没有人在提高iPhone GPS的响应能力方面有任何成功?每一点都有所作为.
编辑1:
正如Apple建议的那样,我的位置管理器位于单件类中.
在SingletonDataController.m中:
static CLLocationManager* locationManager;
locationManager = [CLLocationManager new];
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.headingFilter = kCLHeadingFilterNone;
if(([[UIDevice currentDevice] batteryState] == UIDeviceBatteryStateCharging) || ([[UIDevice currentDevice] batteryState] == UIDeviceBatteryStateFull)) {
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
} else {
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
}
[sharedSingleton setLocationManager:locationManager];
[locationManager release];
Run Code Online (Sandbox Code Playgroud)
在MapView.m内部(实际使用位置管理器):
- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil {
//setup
[SingletonDataController sharedSingleton].locationManager.delegate = self;
//more setup
}
- (void)batteryChanged {
if(([[UIDevice currentDevice] batteryState] == UIDeviceBatteryStateCharging) || ([[UIDevice currentDevice] batteryState] == UIDeviceBatteryStateFull)) {
[SingletonDataController sharedSingleton].locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
} else { …Run Code Online (Sandbox Code Playgroud) 是否可以同时在精灵上运行多个ccactions?例如,如果我有一个CCFadeIn,一个CCScaleTo和一个CCRotateBy,都具有相同的持续时间,我可以同时在精灵上运行所有三个吗?我发现的唯一远程关闭的东西是CCSequence,这不是我想要的.谢谢!
在我的应用程序中,我正在尝试将子视图添加到前面,然后将其放回到其原始图层位置.代码应该非常简单:
要将子视图放在前面(在我的自定义UIView类中):
[self.superview bringSubviewToFront:self];
Run Code Online (Sandbox Code Playgroud)
简单.我将原始z位置存储在一个名为的实例变量中,你猜对了zPosition.所以,前面的行-bringSubviewToFront:是:
zPosition = [self.superview.subviews indexOfObject:self];
Run Code Online (Sandbox Code Playgroud)
所以,我用来将子视图放在前面的所有代码都是:
zPosition = [self.superview.subviews indexOfObject:self];
[self.superview bringSubviewToFront:self];
Run Code Online (Sandbox Code Playgroud)
这应该是正常的.问题是当我尝试将子视图放回原位时.我只是这样做:
[self.superview exchangeSubviewAtIndex:zPosition withSubviewAtIndex:
[self.superview.subviews indexOfObject:self]];
Run Code Online (Sandbox Code Playgroud)
使用此代码,如果我有两个子视图,则会发生以下情况:
假设我有视图A和视图B.视图A在视图B上方.我点击视图B,它来到前面.我再次点击视图B(它应该回到原来的位置),没有任何反应,所以它现在在视图A上.如果我现在点击视图A,它会到达前面,但是当我再次点击它时(所以它应该回到原来的z位置:在视图B)下面,它的所有兄弟视图都消失了!
有谁看到可能导致这个问题的原因?
TensorFlow是否提供了一种重塑Fortran中的张量的方法(列主要顺序?NumPy允许:
a = ...
np.reshape(a, (32, 32, 3), order='F')
Run Code Online (Sandbox Code Playgroud)
我正在尝试将CIFAR图像重塑为32x32x3(来自形状为3072x1的矢量),但我得到的图像看起来像这样:

在Numpy中使用Fortran命令解决了这个问题,但我需要在TensorFlow中做同样的事情.
编辑: 我现在意识到我可以通过重新整形到3x32x32然后转置输出来获得正确的输出.我仍然有点惊讶的是,TF不提供开箱即用的主要或列主要顺序重塑.
ios ×8
calayer ×1
cgpath ×1
filesystems ×1
gps ×1
instruments ×1
iphone ×1
layer ×1
memory-leaks ×1
nsdata ×1
nsurl ×1
numpy ×1
objective-c ×1
performance ×1
python ×1
reshape ×1
sigabrt ×1
subviews ×1
tensorflow ×1
uibezierpath ×1
uikeyboard ×1
uiscrollview ×1
uitextfield ×1
uiview ×1
xcode4 ×1
xib ×1