我希望export class AppClass {
flag: boolean = false;
forwardOption: boolean;
mesasgeList = [];
sendMessage(msg: any) {
this.flag = true;
this.forwardOption = true;
this.mesasgeList.push(msg);
}
get flagVar() {
return this.flag
}
}
根据选择的单元格返回quizNumber
。
例如,如果用户选择了第一个单元格,则quizNumberArray
返回1
在UITableViewController内部
quizNumber
在下一个ViewController中
let quizNumberArray = [1,2,3,4,5,6,7,8,9,10]
var quizNum = Int()
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let vc = storyboard?.instantiateViewController(withIdentifier: "toQuestionVC") as? QuestionVC
quizNum = quizNumberArray[indexPath.row]
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let identifier = segue.identifier {
if identifier == "toQuestionVC" {
let questionController = segue.destination as! QuestionVC
questionController.quizNumber = quizNum
}
但是class QuestionVC : UIViewController {
var quizNumber = Int()
func updateQuestion(){
if quizNumber == 1 {
//.....
}
}
}
返回0。
答案 0 :(得分:0)
尝试以下代码:
final WallpaperManager wallpaperManager = (WallpaperManager)getSystemService(
Context.WALLPAPER_SERVICE);
Bitmap myBitmap = Bitmap.createScaledBitmap(
Const.cropped_bitmap,
wallpaperManager.getDesiredMinimumWidth(),
wallpaperManager.getDesiredMinimumHeight(),
true);
wallpaperManager.suggestDesiredDimensions(
wallpaperManager.getDesiredMinimumWidth(),
wallpaperManager.getDesiredMinimumHeight());
try {
wallpaperManager.setBitmap(myBitmap);
Toast.makeText(CropImageActivity.this,
CropImageActivity.this.getString(R.string.wallpaper_has_been_set), 0).show();
}
catch (IOException e) {
e.printStackTrace();
Toast.makeText(CropImageActivity.this, "Wallpaper not set", 0).show();
}
并删除segue以使用上述代码