只有我第二次使用UICollectionView,也许我已经咬过的东西超过了我可以咀嚼但是:
我正在实现一个UICollectionView(myCollectionView),它使用我已经子类化的自定义UICollectionViewCell.子类化单元格(FullReceiptCell)包含UITableView,并且是viewcontroller的大小.我试图允许FullReceiptCells之间的水平滚动.
包含myCollectionView的子类UICollectionViewController正被推送到导航控制器堆栈.目前,myCollectionView loas和水平滚动已启用.但是,没有细胞可见.我已经证实了这一点
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
Run Code Online (Sandbox Code Playgroud)
已运行并返回一个大于0的整数.我还确认myCollectionView的委托和数据源在IB中正确设置为子类UICollectionViewController.
要加载单元格的方法:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
没有被召唤.
这是我在该控制器中推送UICollectionViewController和viewDidLoad方法的地方(注意:initWithBill是普通初始化程序的覆盖):
在之前的ViewControllers .m文件中:
FullReceiptViewController *test = [[FullReceiptViewController alloc] initWithBill:currentBill];
test.title = @"Review";
[self.navigationController pushViewController:test animated:YES];
Run Code Online (Sandbox Code Playgroud)
在FullReceiptViewController.m中:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self.myCollectionView registerClass:[FullReceiptCell class] forCellWithReuseIdentifier:@"FullReceiptCellIdentifier"];
self.myCollectionView.pagingEnabled = YES;
// Setup flowlayout
self.myCollectionViewFlowLayout = [[UICollectionViewFlowLayout alloc] init];
[self.myCollectionViewFlowLayout setItemSize:CGSizeMake(320, 548)];
[self.myCollectionViewFlowLayout setSectionInset:UIEdgeInsetsMake(0, 0, 0, 0)];
[self.myCollectionViewFlowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
self.myCollectionViewFlowLayout.minimumLineSpacing = 0;
self.myCollectionViewFlowLayout.minimumInteritemSpacing = …
Run Code Online (Sandbox Code Playgroud) 每次打开终端我都会收到以下错误:
Last login: Sun Aug 4 17:23:05 on ttys000
-bash: export: `=': not a valid identifier
-bash: export: `/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin': not a valid identifier
-bash: export: `=': not a valid identifier
-bash: export: `/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin': not a valid identifier
Run Code Online (Sandbox Code Playgroud)
这是我的export
输出:
Calvin:~ sunkehappy$ export
declare -x Apple_PubSub_Socket_Render="/tmp/launch-4lEZNa/Render"
declare -x Apple_Ubiquity_Message="/tmp/launch-ukGAv5/Apple_Ubiquity_Message"
declare -x COMMAND_MODE="unix2003"
declare -x HOME="/Users/sunkehappy"
declare -x LANG="zh_CN.UTF-8"
declare -x LOGNAME="sunkehappy"
declare -x OLDPWD
declare -x PATH="/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
declare -x PWD="/Users/sunkehappy"
declare -x SECURITYSESSIONID="186a4"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare …
Run Code Online (Sandbox Code Playgroud) 我正在创建一个评论部分,就像Facebook在iOS应用程序中使用它的消息部分一样.我希望UITextView
调整高度,以便我输入的文本适合它,而不是你必须滚动才能看到溢出的文本.我有什么想法可以这样做吗?我调查了可能使用的CGRect
是分配给文本视图的大小和高度,然后匹配内容大小:
CGRect textFrame = textView.frame;
textFrame.size.height = textView.contentSize.height;
textView.frame = textFrame;
Run Code Online (Sandbox Code Playgroud)
我假设我需要某种功能来检测文本何时到达边界UITextView
然后调整视图的高度?有没有人在用同样的概念挣扎?
我有一个主要基于核心蓝牙的应用程序.当某些特定事件发生时,使用核心蓝牙背景模式唤醒应用程序并触发警报,但是当应用程序不在前台时,我无法使闹钟正常工作.
我有一个Alarm Singleton类,它初始化AVAudioPlayer
如下:
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:soundName
ofType:@"caf"]];
self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
[self.player prepareToPlay];
self.player.numberOfLoops = -1;
[self.player setVolume:1.0];
NSLog(@"%@", self.player);
Run Code Online (Sandbox Code Playgroud)
这是调用我的警报代码时调用的方法:
-(void)startAlert
{
NSLog(@"%s", __FUNCTION__);
playing = YES;
[self.player play];
NSLog(@"%i", self.player.playing);
if (vibrate) {
[self vibratePattern];
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当应用程序位于前台时,self.player.playing
返回1
当应用程序在后台self.player.playing
返回时0
.为什么会这样?所有代码都被调用,因此应用程序清醒且运行正常.振动工作完美,使用AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
知道为什么这个声音不会播放?
谢谢
我正在使用knockout.js和knockout.validation插件.我正在尝试验证复选框,如果选中它的有效则无效.为此我在淘汰赛中创建了一个自定义的valdation属性:
ko.validation.rule['checked'] = {
validator: function (value) {
if (!value) {
return false;
}
return true;
}
};
Run Code Online (Sandbox Code Playgroud)
而我的观点模型是:
function VM()
{
var self = this;
self.Approve = ko.observable(false).extend({
checked: { message: 'Approval required' }
});
self.Errors = ko.validation.group(self);
self.Validate = function(){
if(self.Errors().length > 0)
self.Errors.showAllMessages();
};
}
Run Code Online (Sandbox Code Playgroud)
但验证不起作用.谁能告诉我这里我做错了什么?
我正在测试AdMob.我是这样做的:
AdManager *adManager = [AdManager sharedAdManager];
adManager.gadBannerView.adUnitID = @"a1514981c9444a4";
adManager.gadBannerView.rootViewController = self;
adManager.gadBannerView.delegate = self;
[adManager.gadBannerView setOriginY:self.view.frame.size.height-adManager.gadBannerView.frame.size.height];
[self.view addSubview:adManager.adBannerView];
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:@"CECADC69-4A6B-4BB4-BF24-CACDA871B44A", nil];
[adManager.gadBannerView loadRequest:request];
Run Code Online (Sandbox Code Playgroud)
而@"CECAD ......"GAD_SIMULATOR_ID.我在模拟器上测试时总是在控制台中出错.在我的设备上也是同样的错误.iOS版本为6.0+.即使我删除了request.testDevices = ...
,我也无法获得任何广告.
"Google":要在此设备上获取测试广告,请调用:request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID,nil];
你好我所有我是目标c的新手,我想动态/编程插入数据到plist.please帮帮我.这是我的plist结构
root
|_Client1
|_report1
|_application1
|_application2
|_report2
|_application3
|_Client2
|_report1
Run Code Online (Sandbox Code Playgroud)
现在我想动态地向application1添加和检索数据,我的plist中的application2请帮帮我
我必须创建自己的自定义滑块.我试图改变拇指图像,滑块的背景,并在一些测试像幻灯片解锁.我试过这样但不起作用
CGRect frame = CGRectMake(0.0, 219.0, 323.0, 20.0);
UISlider *myslider = [[UISlider alloc] initWithFrame:frame];
[myslider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
[myslider setBackgroundColor:[UIColor clearColor]];
[myslider setThumbImage: [UIImage imageNamed:@"sliderThumb@2x.png"] forState:UIControlStateNormal];
myslider.minimumValue = 0.0;
myslider.maximumValue = 50.0;
myslider.continuous = YES;
myslider.value = 15.0;
[self.view addSubview:myslider];
Run Code Online (Sandbox Code Playgroud)
但在这个拇指pic的大小非常大.如何减少拇指pic大小....以及如何给滑块背景和文本.请帮帮我
我的应用程序有一个大问题.主要在iOS 8上,因为我们还没有在其他iOS版本上找到它.
当推送到新的视图控制器或弹出到前一个视图控制器时,它有时会冻结.但奇怪的是,如果你按下主页按钮并从后台启动应用程序.它会运行一点.在这里,我的意思是新推出或弹出的视图控制器出现,但你仍然无法推或弹出新的视图控制器.
更新: 应用程序冻结时内存,CPU和磁盘使用情况都正常.
我目前正在开发一个程序,它可以从我的Core Data设置中动态填充选择器视图.我有一切都在数据方面工作,但我现在遇到的问题是在我的标签上格式化.
选择器在动作表中显示它自己的工具栏,工具栏的右侧有一个按钮.它的初始状态是可见2个刻度盘.按下按钮时,它会变为3个拨盘.
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *pickerLabel = (UILabel *)view;
CGSize limitSize = CGSizeMake(100.0f, 45.0f);
CGSize textSize;
CGRect labelRect;
NSString *title = @"";
switch (numberOfComponents){
case 2:
{
...gets strings from fetched data (varying length from 4 to 20+)
title = someString
}
case 3:
{
...same as above but for the second set of data.
title = someString
}
}
textSize = [title sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:limitSize lineBreakMode:UILineBreakModeWordWrap];
labelRect = CGRectMake(0, 0, textSize.width, …
Run Code Online (Sandbox Code Playgroud) ios ×6
objective-c ×5
iphone ×4
admob ×1
audio ×1
background ×1
bash ×1
cgrect ×1
export ×1
freeze ×1
ios8 ×1
javascript ×1
jquery ×1
knockout.js ×1
macos ×1
plist ×1
slider ×1
terminal ×1
uikit ×1
uilabel ×1
uipickerview ×1
uitextview ×1
xcode ×1