小编mab*_*ble的帖子

Xcode tableview如何在EACH部分中选择一行

我有2个部分的tableview.我希望每个部分只选择一行.现在我让它选择一行,但它适用于整个表格.最终,我想要选择2行,但每个SECTION只需要一行.我已经坚持了几天,无法弄明白.这可能吗??我是Xcode的新手,所以任何帮助都会非常感激.提前致谢!

这是我的代码:

//  OptionsViewController.h

#import <UIKit/UIKit.h>

@interface OptionsViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
{
    NSArray *themeDataArray;
    NSArray *levelDataArray;
    NSIndexPath *selectedRowIndex;
}

@property (weak, nonatomic) NSArray *themeDataArray;
@property (weak, nonatomic) NSArray *levelDataArray;
@property (weak, nonatomic) NSIndexPath *selectedRowIndex;
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end


//  OptionsViewController.m

#import "OptionsViewController.h"
@interface OptionsViewController ()
@end

@implementation OptionsViewController

- (void)viewDidLoad
{
    themeDataArray = [[NSArray alloc] initWithObjects:@"Classic",@"Animals",@"Dinosaurs",@"Cars", nil];
    levelDataArray = [[NSArray alloc] initWithObjects:@"Easy",@"Medium",@"Hard", nil];

    //set default rows on startup
    NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:0];
    [self.tableView selectRowAtIndexPath:indexPath animated:YES  scrollPosition:UITableViewScrollPositionTop]; …
Run Code Online (Sandbox Code Playgroud)

xcode tableview

12
推荐指数
2
解决办法
8157
查看次数

Xcode如何更改哪个viewController在启动时首先加载

我正在使用故事板,xcode 4.6.1.我已经创建了一个应用程序,但现在我想回去并在开头添加一个新的视图控制器.如何将此视图控制器指定为第一个在运行时加载的视图控制器?

xcode storyboard uiviewcontroller

6
推荐指数
1
解决办法
7448
查看次数

如何链接淡出动画

我有3个UILabels我希望在几秒钟后一个接一个地淡出.我的问题是这些都是一下子发生的.我试图链接动画,但我不能让它工作.我尝试了各种各样的建议,但无济于事.我知道这不可能很难.我最好想用一种动画方法将它们捆绑在一起,因为我想animationDidStop在显示所有3个标签之后触发其他功能.任何帮助或建议?

这是我的代码:

- (void)viewDidLoad
{
    [self fadeAnimation:@"fadeAnimation" finished:YES target:lblReady];
    [self fadeAnimation:@"fadeAnimation" finished:YES target:lblSet];
    [self fadeAnimation:@"fadeAnimation" finished:YES target:lblGo];
}


- (void)fadeAnimation:(NSString *)animationID finished:(BOOL)finished target:(UIView *)target
{
    [UIView beginAnimations:nil context:nil];
    [UIView beginAnimations:animationID context:(__bridge void *)(target)];
    [UIView setAnimationDuration:2];

    [target setAlpha:0.0f];
    [UIView setAnimationDelegate:self];    
    [UIView commitAnimations];
}
Run Code Online (Sandbox Code Playgroud)

animation objective-c chaining ios

4
推荐指数
1
解决办法
1571
查看次数

xcode无法获取AVAudioPlayer播放的声音文件

我是iOS的新手,并试图为我的应用添加声音.我已经关注了几个关于向我的项目添加一个简单声音文件的教程,但是所有结果都相同.我没有错误,但没有声音播放.关于我做错了什么的任何想法?任何帮助,将不胜感激!

- (IBAction)playSound:(id)sender {

    NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mp3"];
    NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
    NSLog(soundFilePath);

    NSError *error;
    AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:&error];
    player.numberOfLoops = 1; 

    [player play];

 }
Run Code Online (Sandbox Code Playgroud)

**更新***

所以,我从来没有与上面的代码,这是非常令人沮丧的任何运气,但我没有最终得到它使用AudioToolbox框架,而不是工作,使用此:

SystemSoundID soundID;
NSString *soundFile = [[NSBundle mainBundle]
                       pathForResource:@"test" ofType:@"mp3"];
AudioServicesCreateSystemSoundID((__bridge  CFURLRef)
                                 [NSURL fileURLWithPath:soundFile], & soundID);
AudioServicesPlaySystemSound(soundID);
Run Code Online (Sandbox Code Playgroud)

任何人都可以向我解释差异,为什么这个有效,另一个没有?我比什么都好奇.希望得到一些澄清.

audio xcode avaudioplayer

3
推荐指数
1
解决办法
7638
查看次数