我是iPhone上应用程序开发的新手.根据教程,应该有一个dealloc函数ViewController.m.然而它消失了.还有什么我应该用来释放记忆吗?非常感谢.
iOS 5中的UIColor中有这种方法:
- (BOOL)getHue:(CGFloat *)hue saturation:(CGFloat *)saturation brightness:(CGFloat *)brightness alpha:(CGFloat *)alpha
Run Code Online (Sandbox Code Playgroud)
但我不明白我是如何在代码中使用它的.当然,如果我想从UIColor那里得到它,我当然不需要说明每个组件?
我希望我的头衔有道理.
我有一个iPhone应用程序使用标准UINavigationController方法来推送新的视图控制器,让用户按照自己的意愿导航.
现在,AppDelegate我有一个在计时器上运行的方法,它可以调用Web服务.如果此服务带有特定响应,我希望能够显示UIView(基本上是自定义警报框,但我不想使用UIAlertView该类).
我怎样才能将这个UIView(在其中定义AppDelegate)显示在UIWindow- 并因此在导航控制器推送的任何和所有视图之上?
我正在放置UITextfield和UISwitch实例UITableView.我可检测标记和值,但不知道如何检测它们是否UISwitch还是UITextField?
我打算为每个人设置不同的行动.
我正在将我的项目转换为使用ARC,并遇到了一个特殊问题.我有一个类来管理从网络下载的文件缓存.每个文件都存储在iPhone文件系统中,相关对象保存在我的管理器类中.其他想要使用文件的对象,请求我的经理获取缓存对象,并在需要该文件时保留该文件.
但偶尔,经理会清理缓存,删除旧文件.当然,它不应该删除当时正在使用的文件.在ARC之前,我通过使用关联对象的retainCount检测到:
// if retainCount is 1 then only the cache has a reference to it
if( obj.retainCount <= 1 ) {
[obj deleteFile];
[cache removeObject:obj];
}
Run Code Online (Sandbox Code Playgroud)
这完全有效[是的,我知道有关retainCount不可靠的警告,但根据我的经验,如果retainCount> 1,你肯定知道不止一个对象保留了它]
但是,使用ARC时,不允许再使用retainCount.我可以引入自己的保留计数机制,并要求所有使用文件的对象明确保留和释放文件对象.但那是错误的,而且这正是ARC应该解决的问题.
你知道更好的方法来实现同样的目标吗?
cocoa-touch objective-c retaincount ios5 automatic-ref-counting
我有一个MainViewController,我想添加两个UITableView,每个都有不同的单元格.但是我不想通过检查表委托方法来阻塞我的MainViewController代码,然后对它进行操作.太乱了.
所以我想我会继承UITableView并让它自己处理cellForRow和其他表方法,这样当我想向MainViewController添加一个表时,我只需要
CustomTable *customTable = [[CustomTable alloc] init];
[self.view addSubview:customTable];
Run Code Online (Sandbox Code Playgroud)
并且所有委托方法都将在该类中处理,从而使我的MainViewController混乱.
我接近这个错吗?我应该继承UITableViewController的子类吗?有什么不同?
我想将uislider添加到我的播放器中,这样我就可以在AVPlayer中播放音频时实现擦洗.一旦第一首歌曲播出,uislider将返回原始位置,下一首歌曲将开始播放.如果有人帮助我,我会很感激.这是我的代码.
-(IBAction)goToiPodLibrary:(UIButton *)sender
{
// Create picker view
MPMediaPickerController* picker = [[MPMediaPickerController alloc] init];
picker.delegate = self;
if (userMediaItemCollection) {
MusicTableViewController *controller = [[MusicTableViewController alloc] initWithNibName: @"MusicTableView" bundle: nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController: controller animated: YES];
// else, if no music is chosen yet, display the media item picker
} else {
MPMediaPickerController *picker =
[[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];
picker.delegate = self;
picker.allowsPickingMultipleItems = YES;
picker.prompt = NSLocalizedString (@"Add songs to play", "Prompt in media item …Run Code Online (Sandbox Code Playgroud) 我有一个由多个单词组成的文本文件.它们都被新线分开.
我尝试了什么:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"txt"];
if (filePath) { // This does trigger, so the file is actually found.
NSArray *arr = [filePath componentsSeparatedByString:@"\n"];
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
NSMutableArray * lines = [[NSMutableArray alloc] initWithArray:[filePath componentsSeparatedByString:@"\n"] copyItems: YES];
Run Code Online (Sandbox Code Playgroud)
这两个似乎都不起作用,因为当我使用NSLog读出行时,我似乎只获得了文件路径.你们有人可以帮忙吗?
lines数组似乎只包含一个对象,即文本文件位置的字符串.
我想要一个数组,其中每个字符串是由纺织品中的一行分隔的字符串.
我必须为iPad应用程序绘制如下图所示的图表.有没有免费的原生图表API?
或任何绘制它的帮助......



任何帮助都会很明显.
我想尝试在uitableview中选择所有功能的电子邮件,在同一个按钮点击用户可以勾选或删除所有复选标记,此外用户还可以选择/取消选择行(在didSelectRowAtIndexPath上).我试着做但不能正常工作,这是我的代码.
- (IBAction)selectAll:(id)sender
{
if(myBoolean)
{
for (NSInteger s = 0; s < self.iTable.numberOfSections; s++)
{
for (NSInteger r = 0; r < [self.iTable numberOfRowsInSection:s]; r++)
{
[[self.iTable cellForRowAtIndexPath:[NSIndexPath indexPathForRow:r inSection:s]] setAccessoryType:UITableViewCellAccessoryNone];
}
}
myBoolean = NO;
[_selectUnselectButton setTitle:@"Select all Friends" forState:UIControlStateNormal];
}
else
{
for (NSInteger s = 0; s < self.iTable.numberOfSections; s++)
{
for (NSInteger r = 0; r < [self.iTable numberOfRowsInSection:s]; r++)
{
[[self.iTable cellForRowAtIndexPath:[NSIndexPath indexPathForRow:r inSection:s]] setAccessoryType:UITableViewCellAccessoryCheckmark];
NSLog(@"%d-%d",s,r);
}
}
myBoolean = YES;
[_selectUnselectButton setTitle:@"Unselect all …Run Code Online (Sandbox Code Playgroud) objective-c ×10
cocoa-touch ×9
ios ×7
iphone ×3
uitableview ×2
avplayer ×1
charts ×1
dealloc ×1
ios5 ×1
retaincount ×1
uicolor ×1