我按照教程找到这段代码:
self.imageView.frame = (CGRect){.origin = CGPointMake(0.0f, 0.0f), .size = image.size};
Run Code Online (Sandbox Code Playgroud)
它非常清楚它做了什么,但我不理解这行代码的语法.我第一次看到这样的事情:.size = image.size.在点语法中我希望看到点前面的东西self.view,但是,这是什么意思.size?
第二个问题是 - 为什么有圆括号,后面是大括号?我之前从未见过这样的结构(){};.
我的问题可能听起来很傻,但现在我有点困惑,有人可以提供解释吗?谢谢.
我的应用程序工作得很好,直到我下载新的Xcode,现在它被错误"信号SIGABRT"停止并指出:
[PlaceHolder setDescription:]: unrecognized selector sent to instance 0x79838900
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PlaceHolder setDescription:]: unrecognized selector sent to instance 0x79838900'
Run Code Online (Sandbox Code Playgroud)
我知道,这些信息可能不足以理解发生了什么,但我不知道从哪里开始搜索.如果setter方法有错误,为什么我的应用程序之前有效?是否有任何新的更改阻止应用启动?
PlaceHolder是一个对象,它包含属性(如图像链接,文本等).此外,还有一个新的"黄色"警告 - Auto property synthesis will not synthesize property 'description' because it is 'read-write' but it will be synthesized 'read-only' via another property
我想构建一个UICollectionView,或使用类似的库来制作网格视图,我可以在其中重新排列单元格.我的应用程序支持iOS 7,不幸的是UICollectionView方法 - (BOOL)beginInteractiveMovementForItemAtIndexPath:(NSIndexPath *)indexPath
仅适用于iOS 9及更高版本.
有什么方法可以在iOS7上实现"拖动和重新排序"集合视图单元格的效果吗?谢谢.
我对集合视图单元格有问题.首次加载我的集合视图时,它会显示以下项目:
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{
CalendarCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"CalendarCell" forIndexPath:indexPath];
[cell bindDate:_datesMgr.currentMonthItems[indexPath.row] andNowDate:_datesMgr.nowDate];
// bind events
if (_eventsMgr.eventsArray.count > 0){
for (int i = 0; i < _eventsMgr.eventsArray.count ; i ++) {
[cell bindConference:_eventsMgr.eventsArray[i]];
}
}
return cell;
}
Run Code Online (Sandbox Code Playgroud)
在这些方法中,是将子视图添加到自定义单元类的逻辑,这取决于某些情况.
它的所有工作,但是,当收集视图重新加载(我强制重新加载1秒后)一些单元格被重用并放置在其他单元格上,因此,它显示"旧"图像和子视图.
我可以看到强制uicollection视图停止重用单元格的可能解决方案(每次都加载新单元格).有没有办法做到这一点?
我想将图像居中到UILabel文本第一行的Y中心。我使用砖石来设置“自动布局”约束,如下所示:
[_haveReadIndicatorImgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.equalTo(self.contentView).offset(SMALL_OFFSET);
make.height.width.equalTo(@(8));
}];
[_topTxtlbl mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(_haveReadIndicatorImgView.mas_right).offset(TINY_OFFSET);
make.top.equalTo(_haveReadIndicatorImgView.mas_top);
make.right.equalTo(self.arrowImgView.mas_left).offset(-SMALL_OFFSET);
make.bottom.equalTo(_dateTxtLbl.mas_top).offset(-SMALL_OFFSET);
}];
Run Code Online (Sandbox Code Playgroud)
它应该非常简单。我只是将UIImageView的顶部附加到我的Label的顶部。
但是看看屏幕。
UIImageView的顶部边缘(灰色点)和label相等,但是如何使UIImageView这样居中于文本的第一行呢?
谢谢。
当我试图在iPhone上启动我的应用程序时,我发生了神秘的崩溃(尽管它在Simulator上完全有效).我认为问题在于这两种方法..:
-(void)viewWillAppear:(BOOL)animated{
[self getValueFromPicker];
}
-(void)getValueFromPicker{
NSDate *now = [NSDate date];
NSDate *birthDate = self.birthdayPicker.date;
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit
fromDate:now
toDate:birthDate
options:0];
NSLog(@"Difference in years %i/", components.year);
}
Run Code Online (Sandbox Code Playgroud)
应用程序因SIGABRT 错误而崩溃,并且我可以在控制台中看到一个文本:Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: date'
请帮助我,我真的不知道我做错了什么,当我在控制台的模拟器上做同样的事情我可以看到从现在的日期和日期,用户选择的年数差异.
更新:我删除后[self defaultBirthdayPickerDate]; 在viewDidLoad部分,它开始工作.但是,现在选择器显示当前日期,选择生日日期不是很方便,现在我仍需要将其当前日期从现在改为过去.
我正在研究php,现在我正在努力跟随:我有一个包含其他数组的数组:
$leftMenu = array(
array('link'=>'?????', 'href'=>'index.php'),
array('link'=>'? ???', 'href'=>'about.php'),
array('link'=>'????????', 'href'=>'contact.php'),
array('link'=>'??????? ?????????', 'href'=>'table.php'),
array('link'=>'???????????', 'href'=>'calc.php')
);
Run Code Online (Sandbox Code Playgroud)
我需要做的是使用foreach绘制一个带有html和这个数组的超链接的菜单.这就是我试图做的事情:
foreach ($leftMenu as $key=>$value){
foreach ($value as $html=>$link){
echo "<a href=$html>$link </a>\n";
}
}
Run Code Online (Sandbox Code Playgroud)
显然它不起作用,因为我在变量$ link中得到无效值.我想要的是,只传递给该变量的链接,而不是文本.怎么实现呢?
我研究手动内存管理,我想知道自动释放池何时耗尽.
有三种情况,我发现:1 - 在main.m,从应用程序运行开始,并在结束时排干,因此释放内存中的所有对象.2 - 当您手动显式创建自动释放池并将其耗尽时
第三种情况是我要求的,对我来说有点混乱.
在我研究时,自动释放对象就像C中的自动变量一样,只存在于逻辑范围内(在函数体中).因此,我想在每个函数之后都有一个隐藏的[pool drain];
但是,有人向我指出,我认为这不正确.苹果说,它在"事件"之后消失了.当用户点击按钮时,可能会发生该事件,例如重新加载表视图.
但是这些信息还不足以让人看到整体情况.你能否为我澄清一下,当一个游泳池正好用于物体时NSArray *arr = [NSArray array];?
UILabel如果它有空间,我有那条显示单行.
但是,我需要强制它总是显示2行,即使有足够的空间可以在1行显示它.
强有力的方法是减少正确的间距约束并检查所有可用设备上的条件,但也许有一种更简单的方法?
正如我所提到的,现在标签通过约束绑定到superview.
我知道如何初始化一个不带参数的闭包,如下所示:
class testClass {
var myClosure: () -> ()
init(){
myClosure = {}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我无法弄清楚如何初始化闭包:
var myClosure: (Int) -> ()
Run Code Online (Sandbox Code Playgroud)
我怎么做?
ios ×9
objective-c ×8
autolayout ×2
arrays ×1
cocoa-touch ×1
iphone ×1
php ×1
swift ×1
uilabel ×1
uitableview ×1
xcode ×1
xcode6 ×1