我有一个字符串
11/Passion/01PassionAwakening.mp3
Run Code Online (Sandbox Code Playgroud)
我需要删除最后一个路径组件
01PassionAwakening.mp3
Run Code Online (Sandbox Code Playgroud)
那看起来像
11/Passion
Run Code Online (Sandbox Code Playgroud)
怎么办呢?
我需要两个组件
我有1x,2x和3x类型的图像,分辨率分别为404*750,808*1500和1212*2250.
这是我的代码:
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bgr"]];
Run Code Online (Sandbox Code Playgroud)
在我的iPhone上,背景不会重复,而且很好.但iPad的背景重复了4次.
你知道为什么会这样吗?
我有一个应用程序,因为我需要一个侧栏,就像android中的导航抽屉一样.我见过几个第三方,但似乎它们对我没用.因为我有超过5个ViewControllers,并且在每个ViewController中我需要相同的侧边栏.我该怎么做.我是初学者,请帮忙.
我有一个UIAlertController,我有一堆UIAlertAcion按钮.现在我需要显示一个带有其他颜色而不是相同颜色的按钮.
对于Ex
Button1的
BUTTON2
BUTTON3
Button1和button3应为蓝色
和
button2应为红色.
可能吗 ?怎么样?
只是扔你的想法......
我的代码:
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"Food Menu" message:@"Select the MenuItem" preferredStyle:UIAlertControllerStyleActionSheet];
for(int i= 0; i<[menus count];i++){
UIAlertAction *action = [UIAlertAction actionWithTitle:[menu objectAtIndex:i] style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
[actionSheet dismissViewControllerAnimated:YES completion:nil];
//do SomeWork
}];
if(i==currentIndex){
//Put button Color Red
}
else{
//put button color Blue
}
[actionSheet addAction:action];
}
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction* action){
[actionSheet dismissViewControllerAnimated:YES completion:nil];
}];
[actionSheet addAction:cancel];
[self presentViewController:actionSheet animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud) 我已经编写了一个 mediaPlayer 应用程序,并在mediaplayer.setOnCompletionListener歌曲完成之前调用它,并且每首歌曲都会继续......它会继续播放下一首歌曲,直到到达播放列表中的最后一首歌曲......请帮助
这是我的代码:
tracksListViewForSpeakers.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
Track track = playlistContents.get(position);
String filepath = track.getFilePath();
if (mediaPlayer.isPlaying()) {
mediaPlayer.stop();
}
mediaPlayer.reset();
try {
mediaPlayer.setDataSource(filepath);
mediaPlayer.start();
// mediaPlayer.setVolume(0, 0);
} catch (IOException e) {
e.printStackTrace();
for(int i=0;i<4;i++)
System.out.println("MediaPlayer Exception");
}
}
});
Run Code Online (Sandbox Code Playgroud)
完成监听器
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
onNextClicked(mp);
}
});
Run Code Online (Sandbox Code Playgroud)
OnNextClicked方法
public void onNextClicked(MediaPlayer mp){
int val = myModel.getCurrentPlayingIndex();
val=val+1;
Track track …Run Code Online (Sandbox Code Playgroud)