我有一个iPad应用程序.我正在创建一个UIAlertController并添加一个文本字段.它崩溃了.它只在我添加文本字段时崩溃.
let alert = UIAlertController(title: "Enter Name", message:nil, preferredStyle: UIAlertControllerStyle.Alert);
alert.addTextFieldWithConfigurationHandler { (textfield:UITextField!) -> Void in
textfield.placeholder = "Sexy time";
}
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: {(action:UIAlertAction!) -> Void in
//Some action here
}));
self.presentViewController(alert, animated: true, completion: nil);
Run Code Online (Sandbox Code Playgroud)
我得到一个有趣的崩溃告诉我,约束搞砸了.此代码在<8.3中正常工作,没有任何警告.即使在一个没有任何内容的干净项目中,但是这个代码崩溃了 - 该项目需要成为iPad上的splitview项目.
这是完整的堆栈跟踪加上奇怪的约束警告,只有在尝试将文本字段添加到alertController后才会出现.
2015-04-10 15:25:07.155 Observation[18235:281813] The view hierarchy is not prepared for the constraint: <NSLayoutConstraint:0x7fb66cf9dfc0 UITableView:0x7fb66b855000.left == UIView:0x7fb66fae68e0.left>
When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash …
Run Code Online (Sandbox Code Playgroud) 因此,我试图模拟折纸类型纸张折叠,同时添加和删除单元格,就像偷看日历应用程序:
通过继承UITableView并重写insertRowsAtIndexPaths:withRowAnimation:和deleteRowsAtIndexPaths:withRowAnimation,我已经非常接近这个功能了:
但是现在我似乎无法让动画看起来正确.下面是我目前的代码 - 我只想帮助克服这最后的障碍(或者可能有一种完全不同的方法,例如向tableviewcell添加tableview).
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths
withRowAnimation:(UITableViewRowAnimation)animation
{
[super insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
float duration = .30;
int i = 0;
for (NSIndexPath *indexPath in indexPaths) {
__block UITableViewCell *cell = [super cellForRowAtIndexPath:indexPath];
if (cell) { // If indexPath isn't visible we'll get nil here
//even cells flip up while odd cells flip down
if(i % 2 ==0){
cell.layer.anchorPoint = CGPointMake(.5, 0);
//start row off by rotating 90 degrees
__block CATransform3D t = CATransform3DIdentity;
t = CATransform3DTranslate(t, 0, -cell.bounds.size.height/2, 0); …
Run Code Online (Sandbox Code Playgroud) 我知道这可能是一个愚蠢的问题,但我最难将Date转换为字符串SimpleDateFormat
.我有一个当地的约会
"Thu Jul 18 18:56:51 PDT 2013"
我试图直接以格式转换它
"YYYY-MM-dd'T'hh:MM:SS".
我希望字符串看起来像这样:
"2013-07-18T18:56:51"
我得到的是这样的:
"2013-07-18T06:56:51"
任何帮助,将不胜感激.