下面的代码适用于iOS 9.x或更低版本,由于某种原因,如果iOS 10不起作用
if([MFMessageComposeViewController canSendText])
{
controller.body = message;
NSString *tel = pContact.tlc;
controller.recipients = pContact.tlc?@[tel]:nil;
controller.messageComposeDelegate = self;
controller.navigationBar.tintColor = [UIColor whiteColor];
controller.navigationBar.barTintColor = [UIColor blueColor];
[self presentViewController:controller animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
它是破碎还是做了一些改变.不知道这里遗漏了什么.我在黑暗中(漆黑)
编辑:我试图在一个新的空单视图项目上使用一些测试代码,我遇到了同样的问题.
@IBAction func SMS(_ sender: AnyObject) {
let composeVC = MFMessageComposeViewController()
composeVC.messageComposeDelegate = self
// Configure the fields of the interface.
composeVC.recipients = ["5555555555"]
composeVC.body = "Hello from California!"
composeVC.navigationBar.tintColor = UIColor.green
composeVC.navigationBar.barTintColor = UIColor.purple
// Present the view controller modally.
self.present(composeVC, animated: true, completion: nil)
} …Run Code Online (Sandbox Code Playgroud) 我有一个实体,我将一些 ID 设置为 UUID 对象。我有这个函数来检查它是否已经记录在持久性存储中。
我发现某种形式的示例不起作用,因为该示例使用了一些NSPredicate(format: "%K == %@", #KeyPath(attribute), id)在 swift 中不起作用的“ ”代码。
所以我试图弄清楚如何快速解决这个问题。我不想将 UUID 存储为简单的字符串,因为 coreData 允许我们保存 UUID 对象。
我有这个方法,但它在 NSPredicate 行上崩溃:
static func isKnownBikeID(_ bleID: UUID) -> Bool {
let context = A18DataStore.shared.viewContext
let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: "Bike")
fetchRequest.predicate = NSPredicate(format: "%K == %@", [\Bike.bleID , bleID] as CVarArg)
do{
let bikes = try context.fetch(fetchRequest)
return bikes.count > 0
}
catch let error as NSError {
print("Could not fetch. \(error), \(error.userInfo)")
}
return false
} …Run Code Online (Sandbox Code Playgroud) (编辑:最初我收到一个 null 异常,在删除应用程序中心 Nugets 后,此异常移至 TagetInlogging,最后现在收到此异常:System.IO.FileNotFoundException)
我正在尝试将 Xamarin Forms 应用程序迁移到 MAUI。我尝试了几种方法来从包括 MS 在内的各种来源做到这一点。最后,我刚刚创建了一个新应用程序,并将我的文件移动到新项目,并更新了 .cs 和 .xaml 文件中需要的内容。删除了不兼容的 Nuget 以及与其关联的代码。
剩下的金块是:
所以我是应用程序可以编译的地方。但当我启动时,它将崩溃并出现异常“System.IO.FileNotFoundException”。InitializeComponent();它被抛出到App 类构造函数中的for 行。
App 类和 xaml 文件与创建项目时相同。
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:EGrid18"
x:Class="EGrid18.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Run Code Online (Sandbox Code Playgroud)
namespace EGrid18;
public partial class App: Application {
public App() {
InitializeComponent();
MainPage = new AppShell();
}
}
Run Code Online (Sandbox Code Playgroud)
这是堆栈跟踪(已编辑)。
at System.Reflection.Assembly.Load(AssemblyName assemblyRef, …Run Code Online (Sandbox Code Playgroud) colors ×1
core-data ×1
ios ×1
maui ×1
mfmessagecomposeviewcontroller ×1
migration ×1
nspredicate ×1
swift ×1
uuid ×1
xamarin ×1