我刚开始学习UICollectionViews.我想知道是否有人知道如何指定集合视图中的列数.默认设置为3(iPhone /肖像).我查看了文档,似乎无法找到简明的答案.
我想弄清楚当屏幕第一次加载时如何一直滚动到UICollectionView的底部.触摸状态栏时我可以滚动到底部,但我希望能够在视图加载时自动执行此操作.如果我想在触摸状态栏时滚动到底部,下面的工作正常.
- (BOOL)scrollViewShouldScrollToTop:(UITableView *)tableView
{
NSLog(@"Detect status bar is touched.");
[self scrollToBottom];
return NO;
}
-(void)scrollToBottom
{//Scrolls to bottom of scroller
CGPoint bottomOffset = CGPointMake(0, collectionViewReload.contentSize.height - collectionViewReload.bounds.size.height);
[collectionViewReload setContentOffset:bottomOffset animated:NO];
}
Run Code Online (Sandbox Code Playgroud)
我试过在viewDidLoad中调用[self scrollToBottom].这不起作用.有关如何在视图加载时滚动到底部的任何想法?
有没有人知道如何在显示集合视图时重新加载/刷新UICollectionView?基本上我正在为UITableview寻找类似于标准reloadData方法的东西.
我正在开发一个 iOS 应用程序,它要求用户使用键盘类型 UIKeyboardTypeDecimalPad 在 UITextField 中输入数字。然而我刚刚意识到不支持输入负数,这是应用程序的要求。
关于如何实现这一目标有什么想法或想法吗?
我正在尝试了解AVAudioPlayer和音频电平计量.我下面的内容是一个播放短音频声音的"AudioPlayer"对象.现在我想输出这个声音的功率(分贝).不知怎的,我不认为我这样做是对的.
audioPlayer.meteringEnabled = YES;
[audioPlayer play];
int channels = audioPlayer.numberOfChannels;
[audioPlayer updateMeters];
for (int i=0; i<channels; i++) {
//Log the peak and average power
NSLog(@"%d %0.2f %0.2f", i, [audioPlayer peakPowerForChannel:0],[audioPlayer averagePowerForChannel:0]);
Run Code Online (Sandbox Code Playgroud)
NSLog输出为0 -160.00 -160.00 1 -160.00 -160.00
现在根据Apple"0 dB的返回值表示满量程或最大功率; -160 dB的返回值表示最小功率"这是否意味着此声音处于最小功率?我不认为这是真的,因为音频片段是一个相当响亮的声音.我想我在这里遗漏了一些东西,任何澄清都会受到赞赏.
我试图找出如何在UIScrollView上叠加UIButton.基本上用户可以正常使用滚动视图.但是,滚动视图右上角的按钮将保持固定位置.有什么想法吗?
我是iOS开发的新手,只是有一个简单的问题.我正在用100 UILabel创建一个应用程序.每个标签编号为0到99.问题是我不想对所有100个标签执行此操作.
output1.text = [[NSString alloc] initWithFormat:@"1"];
output2.text = [[NSString alloc] initWithFormat:@"2"];
.....
output100.text = [[NSString alloc] initWithFormat:@"100"];
Run Code Online (Sandbox Code Playgroud)
相反,我想更动态地做这件事.下面我试图使用循环动态创建一个字符串.例如,通过将"1.text"附加到"output"的末尾,我得到字符串"output1.text".
for (int i=0; i< 100; i++) {
outputNameString = [NSMutableString stringWithCapacity:0];
[outputNameString setString:@"output"];
[outputNameString appendString:[NSString stringWithFormat:@"%i.text",i + 1]];
outputNameString = [[NSString alloc] initWithFormat:@"%@",i];
}
Run Code Online (Sandbox Code Playgroud)
"output1"到"output100"在接口部分正确声明并正确合成.我在这里缺少什么,或者这根本不可能?任何帮助,将不胜感激.
在处理属性时,我对于正确的约定有点困惑.我将通过一个例子说明我的问题.所以从下面的例子我知道功能上"self.loan = self.loan + 250.00;" 与"_loan = _loan + 250.00;"相同 还是不是?我在网上看到很多教程,可能会也可能不会使用这两种方法来访问属性.那么使用_loan和self.loan之间究竟有什么区别(我知道self.loan与[self setLoan:]相同)
//ClassA.h
@interface ClassA: UIViewController
@property double loan;
@end
//ClassA.m
@implementation ClassA
@synthesize loan = _loan;
-(void)doSomething{
self.loan = self.loan + 250.00; //Exhibit A
_loan = _loan + 250.00; // Exhibit B
}
Run Code Online (Sandbox Code Playgroud) 所以Apple在他们的应用程序提交指南中提到,如果应用程序泄漏内存,它将被拒绝.我的问题是,Apple究竟如何检测内存泄漏?
显然,如果应用程序崩溃,那么它可能是主要内存泄漏的迹象,但对于使用少量内存的应用程序呢(因此如果泄漏内存则不一定会崩溃)
我在查找热门时遇到一些麻烦,在一次动作中两次更新UILabel.基本上用户点击播放按钮来听到声音.当声音播放时,"消息1"出现在UILabel中.当声音完成播放时,"消息2"出现在同一标签中.当我运行此标签时,标签直接转到"消息2".
.H
@interface ViewController : UIViewController
<AVAudioRecorderDelegate, AVAudioPlayerDelegate>
{
AVAudioPlayer *audioPlayer;
UIButton *playButton;
UILabel *answerLabel;
}
@property (nonatomic, retain) IBOutlet UIButton *playButton;
@property (nonatomic, retain) IBOutlet UILabel *answerLabel;
-(IBAction) play;
@end
Run Code Online (Sandbox Code Playgroud)
.M
-(IBAction) play
{
int length = [audioPlayer duration];
[audioPlayer play];
answerLabel.text = @"Message 1";
[NSThread sleepForTimeInterval:length];
answerLabel.text = @"Message 2";
}
Run Code Online (Sandbox Code Playgroud) objective-c ×9
ios ×6
iphone ×6
xcode ×6
ipad ×5
uiscrollview ×2
properties ×1
reloaddata ×1
uikeyboard ×1
uilabel ×1
uitextfield ×1