我正在分享一些内容UIActivityController.
它适用于其他选项.
我能得到subject并且body在默认的邮件应用程序.
但当我用来共享内容时,gmail我Subject的邮件已经消失,我Body在Gmail Subject's部分获取内容:
这是我的代码:
NSString *body = @"I am Body";
NSString *tagLine = @"I am Subject";
NSArray *objectToShare = [NSArray arrayWithObjects:body, nil];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectToShare applicationActivities:nil];
[activityVC setValue:tagLine forKey:@"subject"];
NSArray *excludeActivities = @[UIActivityTypeAirDrop,
UIActivityTypePrint,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToVimeo];
activityVC.excludedActivityTypes = excludeActivities;
[self presentViewController:activityVC animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
为了更好的图片这里是截图:
使用默认应用:
我也尝试过不同的答案.但它们都不起作用.
我QR Code使用以下代码制作图像表格:
func createQRFromString(str: String) -> CIImage? {
let stringData = str.dataUsingEncoding(NSUTF8StringEncoding)
let filter = CIFilter(name: "CIQRCodeGenerator")
filter?.setValue(stringData, forKey: "inputMessage")
filter?.setValue("H", forKey: "inputCorrectionLevel")
return filter?.outputImage
}
Run Code Online (Sandbox Code Playgroud)
然后我添加到UIImageView这样:
if let img = createQRFromString(strQRData) {
let somImage = UIImage(CIImage: img, scale: 1.0, orientation: UIImageOrientation.Down)
imgviewQRcode.image = somImage
}
Run Code Online (Sandbox Code Playgroud)
现在我需要将其保存到文件JPEG或PNG文件中.但是,当我这样做时,我的应用程序崩溃:
@IBAction func btnSave(sender: AnyObject) {
// // Define the specific path, image name
let documentsDirectoryURL = try! NSFileManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: true)
// …Run Code Online (Sandbox Code Playgroud) 我刚刚编写Five了代码行和应用程序崩溃.我检查了很多次,但我无法跟踪代码中的错误.
我添加了框架..没有警告没有错误,但为什么该死的应用程序崩溃:
#import "ViewController.h"
#import <HueSDK_iOS/HueSDK.h>
@interface ViewController ()
@property (strong, nonatomic) PHHueSDK *phHueSDK;
@property (nonatomic, strong) PHBridgeSearching *bridgeSearch;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.phHueSDK = [[PHHueSDK alloc] init]; //Line 1
[self.phHueSDK enableLogging:YES]; //Line 2
[self.phHueSDK startUpSDK]; //Line 3
self.bridgeSearch = [[PHBridgeSearching alloc] initWithUpnpSearch:YES andPortalSearch:YES andIpAdressSearch:YES]; //Line 4
// Start search for bridges
[self.bridgeSearch startSearchWithCompletionHandler:^(NSDictionary *bridgesFound) {
// Search is complete, handle results (dictionary contains IP and mac addresses of bridges found)
}]; Line 5 …Run Code Online (Sandbox Code Playgroud) 我正在尝试将Google Analytics用于我的应用.
但是在通过CocoaPod添加后立即出现此错误:
以前我的pod中有GoogleMaps和GCM.
现在我的Pod看起来像这样:
platform :ios, '8.0'
pod 'Google/Analytics'
pod 'Google/CloudMessaging'
pod 'GoogleMaps'
Run Code Online (Sandbox Code Playgroud)
我该如何解决此错误:
*编辑
这解决了我的问题:
如果我运行现有项目,X-Code 7那么我没有得到错误.
但我想让它运行Xcode 6.4所以我添加旧版本,GA并且可以正常运行X-Code 6.4.
我已经手动添加了较旧sdk但是如果有人想要添加它通过Cocoa-Pod那么这是这样做的方式:
pod 'Google/Analytics'
pod 'GoogleAnalytics', '3.13.0'
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用react-table.
我被困在做一两件事,即改变CSS的columns同时,一列正在调整.
目前,当您resize的列只cursor更改时.我想要的是添加border到selected column.
我搜索了这对SO和google也.但找不到任何有用的东西.在文档中也没有提到关于这个主题的内容.
更新
现在,我可以在调整大小时拖动列时添加边框.我可以通过添加和删除类来实现.
我这样做了:
为className创建了一个var的状态:
this.state = {
addBorder: null
}
Run Code Online (Sandbox Code Playgroud)
在我的专栏中传递了这个类名:
const columns = [{
Header: 'Name',
accessor: 'name', // String-based value accessors!,
headerClassName: this.state.addBorder,
className: this.state.addBorder
}, {
Header: 'Age',
accessor: 'age',
Cell: props => <span className='number'>{2}</span> // Custom cell components!
}, {
id: 'friendName', // Required because our accessor is not a string
Header: 'Friend …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中实现了推送通知.
当我的应用程序在前台时,我的应用程序正常工作.
但当应用程序在后台或被杀时,我的didReceiveRemoteNotification被叫两次.
我已经提出了一个处理Push通知并从didFinishLaunchingWithOptions和 调用此方法的常用方法didReceiveRemoteNotification
这是我的实施:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSDictionary *pushDictionary = [launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (pushDictionary) {
[self customPushHandler:pushDictionary];
}
return YES;
}
Run Code Online (Sandbox Code Playgroud)
而且:
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler {
[self customPushHandler:userInfo];
}
Run Code Online (Sandbox Code Playgroud)
和:
- (void) customPushHandler:(NSDictionary *)notification {
// Code to push ViewController
NSLog(@"Push Notification"); //Got it two times when Clicked in notification banner
}
Run Code Online (Sandbox Code Playgroud)
当我的应用程序运行时,ViewController被推送一次.当我打开我的应用程序从通知横幅,然后我的屏幕被推了两次.
我放置了一个NSLog,customPushHandler当App处于前台时,我得到了一次,当我从Notification banner中启动时,我得到了两次.
我的代码中有什么问题.
我正在为我的应用程序编写单元测试用例.有一个函数在Utils部分编写并在所有文件中使用.我想在需要的时候模拟这个Utils功能,但我无法这样做.
这是我的代码设置:
Utils.js
> const getData = (name) => "Hello !!! " + name;
>
> const getContact = ()=> return Contacts.mobile;
>
> export {
> getData,
> getContact }
Run Code Online (Sandbox Code Playgroud)
Login.js(使用Utils.js)
const welcomeMessage = (name) => {
return getData(name);
}
Run Code Online (Sandbox Code Playgroud)
我的测试文件(Login.spec.js)
import { getData } from '../../src/utils';
jest.mock('getData', () => jest.fn())
describe('User actions', () => {
it('should get username', () => {
const value = 'Hello !!! Jest';
expect(welcomeMessage('Jest')).toEqual(value);
});
});
Run Code Online (Sandbox Code Playgroud)
当我运行我的测试用例时,我收到此错误:
Cannot find module 'getData' from 'Login.spec.js'
Run Code Online (Sandbox Code Playgroud)
我试图在官方Jest文档和SO上找到解决方案但是找不到任何东西.我无法修复此错误并模拟此功能.
在我的 ReactJS 应用程序中,我需要添加放大/缩小功能。我正在使用react-pdf在我的网络应用程序中显示 PDF。文档的A/C有一个scale prop我可以使用它scale的 pdf 页面。
但是使用scale prop并没有向我显示zoom因子的任何变化。这是code我用来这样做的。
<Document
loading=""
file={file}
className="document"
onLoadSuccess={(transport) => onLoadSuccess(transport, sectionIndex)}>
<Page width={900} scale={30} className="page" pageNumber={1} />
</Document>
Run Code Online (Sandbox Code Playgroud)
我试过以下值,scale prop但似乎没有得到任何东西。1.5、0.5、10、30、40。有没有更好的方法来做同样的事情,或者我错过了什么?
我有一个小组件,带有一些文本。
在useEffect中,我只是将元素的顶部设置为一些值。
CSS:
.box {
display: flex;
flex-direction: column;
position: relative;
top: 0;
transition: top 0 ease-in;
}
useEffect(() => {
setTimeout(()=> { // with this it is working.
const elems = document.getElementsByClassName("box");
[...elems].forEach(function (e) {
e.style.top =`-200px`; // without settimeout transition is not working
});
});
}, []);
Run Code Online (Sandbox Code Playgroud)
我的标记:
<div className='progress'>
<div className='box' />
<div className='box' />
<div className='box' />
</div>
Run Code Online (Sandbox Code Playgroud)
现在,当我频繁刷新时,我会看到转换发生了几次,但不是每次都发生。
但是当我将代码包装在 setTimeout 中时,我每次都会看到一个转换。
我不知道为什么会发生这种情况。
ios ×5
objective-c ×4
reactjs ×4
javascript ×3
xcode6 ×3
swift3 ×2
animation ×1
ciimage ×1
css ×1
gmail ×1
ios11 ×1
iphone ×1
jestjs ×1
pdf ×1
pdfjs ×1
philips-hue ×1
react-pdf ×1
react-table ×1
resize ×1
swift ×1
uiimage ×1
unit-testing ×1