我有一个导航,初始网址如下所示:
test.php?query=19
我的页面上有链接 <a href="#section-1">Section 1</a><a href="#section-2">Section 2</a><a href="#section-3">Section 3</a>
有3个部分:
<section id="section-1"></section><section id="section-2"></section><section id="section-3"></section>
Run Code Online (Sandbox Code Playgroud)
我正在使用此jquery代码从页面顶部(或用户在页面上的位置)滚动到该部分到该部分的顶部,而不是#在我的网址中显示标记.
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 2000);
return false;
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
我的问题是,这不会滚动到该部分.它只是转到该部分的底部,然后滚动到顶部,并#显示在我的网址中.
我的主页上有另一个菜单:
home.php 我使用完全相同的jquery代码,它适用于该页面.
我的问题是如何让ScrollTop在我的test.php?query=19页面中工作就像home.php在我点击test.php?query=19我的网址上的内容时更改为:test.php?query=19#section-1
我有2个应用程序,一个是表单身份验证,看起来像这样:
<authentication mode="Forms">
<forms loginUrl="~/Login"></forms>
</authentication>
public class LoginController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult LoginCheck()
{
string username = Request.Form["username"];
FormsAuthentication.RedirectFromLoginPage(username, true);
return RedirectToAction("Index", "Home");
}
}
Run Code Online (Sandbox Code Playgroud)
另一个应用程序是空的但使用Windows身份验证:
<authentication mode="Windows" />
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Title = "Home Page";
return View();
}
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是以下内容:
用户在表单身份验证应用程序中填写用户名和密码,然后单击"提交"
LoginCheck方法获取用户名和密码,并针对Windows身份验证应用程序进行身份验证
我希望我从Windows身份验证应用程序得到回复,说是这个用户名和密码是正确的,继续或不是他们不工作
我是否正确地想要完成什么?我的问题是我不知道如何完成第2部分,如果有人可以帮助我,这将是惊人的或指向我正确的方向.
c# asp.net authentication forms-authentication windows-authentication
我从存储过程中获取XML输出.我想要做的是获取XML并通过ASP.NET传递出来:
public XmlDocument GetPunchListXml(string communityDesc)
{
try
{
using (connection = new SqlConnection(connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand("GetPunchList", connection))
{
command.CommandType = CommandType.StoredProcedure;
SqlParameter parameter1 = new SqlParameter("@communityDesc", SqlDbType.VarChar);
parameter1.Value = communityDesc;
parameter1.Direction = ParameterDirection.Input;
command.Parameters.Add(parameter1);
var doc = new XmlDocument();
var reader = command.ExecuteXmlReader();
if (reader.Read())
{
doc.Load(reader);
}
return doc;
}
}
}
finally
{
connection.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
但我一直收到这些错误:
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
The 'ObjectContent`1' type failed to serialize the response body for …Run Code Online (Sandbox Code Playgroud) 我有一个问题,即通过ASP.NET从SQL数据库获取数据,然后将数据传递给Objective-C.目前我只是使用SQL select语句通过ASP.NET从数据库中获取数据,ASP.NET返回如下数据:
<ArrayOfKeyValueOfstringPunchListCellModel84zsBx89 xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<KeyValueOfstringPunchListCellModel84zsBx89>
<Key>ORC0023</Key>
<Value xmlns:d3p1="http://schemas.datacontract.org/2004/07/LHS.Models">
</Value>
</KeyValueOfstringPunchListCellModel84zsBx89>
</ArrayOfKeyValueOfstringPunchListCellModel84zsBx89>
Run Code Online (Sandbox Code Playgroud)
然后在Objective-C中,我将数据放入NSDictionary中,如下所示:
NSDictionary *punchList = [[NSDictionary alloc]initWithDictionary:[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&myError]];
Run Code Online (Sandbox Code Playgroud)
一切都在这里按预期工作.
我现在正在做的是创建一个返回XML的存储过程,并让ASP.NET返回XML(这里的所有内容都已完成并按预期工作)XML如下所示:
<KeyValueOfstringPunchListCellModel84zsBx89>
<Key>ORC0023</Key>
<Value>
</Value>
</KeyValueOfstringPunchListCellModel84zsBx89>
</ArrayOfKeyValueOfstringPunchListCellModel84zsBx89>
Run Code Online (Sandbox Code Playgroud)
现在对于Objective-C粉丝,您知道除非您使用第三方项目/库,否则您无法在NSDictionary中使用XML.
现在我的问题是,我是否重做了我的存储过程以返回JSON,还是有另一种方法可以解决这个问题?
我的最终目标是尽可能快地完成流程,并且SQL查询很大并且返回很多行.
我正在将PDF加载到a中UIWebview,我更改了背景颜色以清除并将opaque设置为false.但是现在我有一个填充或边距UIWebView我想删除所以UIWebview屏幕是.
我创建了UIWebview这样的:
let webview = UIWebView()
webview.frame = self.view.bounds
webview.scrollView.frame = webview.frame
webview.userInteractionEnabled = true
webview.scalesPageToFit = true
webview.becomeFirstResponder()
webview.delegate = self
webview.scrollView.delegate = self
webview.opaque = false
webview.backgroundColor = UIColor.clearColor()
self.view.addSubview(webview)
webview.loadRequest(NSURLRequest(URL:url))
webview.gestureRecognizers = [pinchRecognizer, panRecognizer]
Run Code Online (Sandbox Code Playgroud)
我将此应用于webViewDidFinishLoad方法
func webViewDidFinishLoad(webView: UIWebView) {
let padding = "document.body.style.margin='0';document.body.style.padding = '0'"
webView.stringByEvaluatingJavaScriptFromString(padding)
}
Run Code Online (Sandbox Code Playgroud)
但仍有填充或边距,它看起来像这样:
我该如何解决?
我需要修复这个问题的原因是因为我要将这个UIWebView保存为PDF,当我保存它时,还有额外的间距,这里是我的PDF生成代码:
func drawPDFUsingPrintPageRenderer(printPageRenderer: UIPrintPageRenderer) -> NSData! {
let data = NSMutableData()
UIGraphicsBeginPDFContextToData(data, CGRectZero, nil)
UIGraphicsBeginPDFPage()
printPageRenderer.drawPageAtIndex(0, inRect: UIGraphicsGetPDFContextBounds())
UIGraphicsEndPDFContext()
return …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建日历,而不是日历事件而是日历.我无法获取本地来源,我的应用程序崩溃了.
这是我的代码:
let newCalendar = EKCalendar(for: .event, eventStore: eventStore)
newCalendar.title = "Some Calendar Name"
let sourcesInEventStore = eventStore.sources
newCalendar.source = sourcesInEventStore.filter{
(source: EKSource) -> Bool in
source.sourceType.rawValue == EKSourceType.local.rawValue
}.first!
Run Code Online (Sandbox Code Playgroud)
我完全关闭了我的iCloud,仍然无法获得本地资源.
我也试图让这个与iCloud打开工作,我想出了这个代码,但它不起作用
for let source in eventStore.sources
{
if(source.sourceType == EKSourceType.calDAV && source.title == "iCloud")
{
newCalendar.source = source
}
}
if(newCalendar.source == nil)
{
for let source2 in eventStore.sources
{
if(source2.sourceType == EKSourceType.local)
{
newCalendar.source = source2
}
}
}
Run Code Online (Sandbox Code Playgroud) 这里有我的访问密钥,
https://api.instagram.com/v1/users/MY_USER_ID/media/recent?access_token=MY_ACCESS_KEY
Run Code Online (Sandbox Code Playgroud)
但它只返回1项.
我搜索了一个解决方案,但似乎找不到一个.
这个工作大约一个月前,现在已经坏了.
我删除了旧客户端,创建了一个新客户端并生成了一个新的access_token.
但它保持相同的结果.
我的问题是:
如何在一个月前得到相同的结果?
我通过freevision.me/instagram获取了访问令牌,
并按照这些说明doc.freevision.me/adventure/knowledge-base/get-instagram-client-id获取了我的客户端ID .
我正在使用UNUserNotificationCenter来发送通知,如下所示:
UNUserNotificationCenter.current().getDeliveredNotifications { (notifications) in
self.array = notifications
}
Run Code Online (Sandbox Code Playgroud)
然后在viewWillDisappear上我清除applicationIconBadgeNumber,如下所示:
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
UIApplication.shared.applicationIconBadgeNumber = 0
}
Run Code Online (Sandbox Code Playgroud)
这样做不会让我的通知持续很长时间,是的,我希望看到通知后徽章编号为0,但我希望这些编号可以持续24-48小时....我怎么能完成这个?
当我尝试访问我的phpmyadmin localhost时,我收到两个错误
Access denied for user 'root'@'localhost' (using password: YES)
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
Run Code Online (Sandbox Code Playgroud)
我不知道我做错了什么...这是我的配置代码...
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/*
* Servers configuration
*/
$i = 0;
/*
* First server
*/
$i++; …Run Code Online (Sandbox Code Playgroud) 我正在Swift 4中构建一个iOS应用程序,我正在尝试向用户Apple Music Library添加一首歌,我能够像我这样得到我的Apple音乐库:
mediaPicker = MPMediaPickerController(mediaTypes: .anyAudio)
mediaPicker?.showsCloudItems = false
mediaPicker?.showsItemsWithProtectedAssets = false
if let picker = mediaPicker{
picker.delegate = self
picker.allowsPickingMultipleItems = false
present(picker, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
但是可以将歌曲上传到用户Apple Music Library吗?
以下是我如何获取要添加到用户Apple Music Library的音频文件
let audioString = (result[0]["audio"] as! String).addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)
let audioUrl = URL(string:"http://example.com/uploads/" + audioString!)
Alamofire.request(audioUrl!).responseData { response in
do {
self.audio = try AVAudioPlayer(data: response.data!)
self.audio?.prepareToPlay()
}catch{
}
}
Run Code Online (Sandbox Code Playgroud)
UPDATE
我找到了这个:https://stackoverflow.com/a/17433006/979331现在我有两个问题,我如何将其转换为Swift,如果我使用ScriptingBridge,当我将我的应用程序提交到应用程序商店时,这是允许的吗?